# MLXRCpuDepthFeature

This feature provides functionality for working with camera depth data from Unity ARFoundation.

{% hint style="success" %}
This class is distributed in the [`ai.natml.natml.arfoundation`](https://github.com/natmlx/NatML-ARFoundation) integration library.
{% endhint %}

## Creating the Feature

```csharp
/// <summary>
/// Create an AR depth image feature.
/// </summary>
/// <param name="image">Augmented reality image.</param>
/// <param name="camera">AR session camera.</param>
/// <param name="orientation">Image orientation. If `Unknown`, this will default to the screen orientation.</param>
MLXRCpuDepthFeature (XRCpuImage image, Camera camera, ScreenOrientation orientation = 0);
```

INCOMPLETE.

## Inspecting the Feature

The depth feature exposes its underlying `type`, along with convenience properties for inspecting the aforementioned `type`.

### Feature Type

```csharp
/// <summary>
/// Feature type.
/// </summary>
MLFeatureType type { get; }
```

Refer to the [Inspecting the Feature](/unity/api/mlfeature.md#inspecting-the-feature) section of the [`MLDepthFeature`](/unity/api/mlfeature/mldepthfeature.md#feature-type) class for more information.

### Depth Map Width

```csharp
/// <summary>
/// Depth map width.
/// </summary>
int width { get; }
```

Refer to the [Depth Map Width](/unity/api/mlfeature/mldepthfeature.md#depth-map-width) section of the [`MLDepthFeature`](/unity/api/mlfeature/mldepthfeature.md) class for more information.

### Depth Map Height

```csharp
/// <summary>
/// Depth map height.
/// </summary>
int height { get; }
```

Refer to the [Depth Map Height](/unity/api/mlfeature/mldepthfeature.md#depth-map-height) section of the [`MLDepthFeature`](/unity/api/mlfeature/mldepthfeature.md) class for more information.

## Sampling Pixel Depth

```csharp
/// <summary>
/// Sample the depth feature at a given point.
/// </summary>
/// <param name="point">Point to sample in normalized coordinates.</param>
/// <returns>Depth in meters.</returns>
float Sample (Vector2 point);
```

Refer to the [Sampling Pixel Depth](/unity/api/mlfeature/mldepthfeature.md#sampling-pixel-depth) section of the [`MLDepthFeature`](/unity/api/mlfeature/mldepthfeature.md) class for more information.

## Projecting to 3D Space

```csharp
/// <summary>
/// Project a 2D point into 3D world space using depth.
/// </summary>
/// <param name="point">Point to transform in normalized camera coordinates.</param>
/// <returns>Projected point in 3D world space.</param>
Vector3 ViewportToWorldPoint (Vector2 point);
```

Refer to the [Projecting to 3D Space](/unity/api/mlfeature/mldepthfeature.md#projecting-to-3d-space) section of the [`MLDepthFeature`](/unity/api/mlfeature/mldepthfeature.md) class for more information.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.natml.ai/unity/api/mlfeature/mlxrcpudepthfeature.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
