# Depth

Artifact: [androidx.xr.arcore:arcore](https://developer.android.com/jetpack/androidx/releases/xr-arcore) [View Source](https://cs.android.com/search?q=file:androidx/xr/arcore/Depth.kt+class:androidx.xr.arcore.Depth) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

*** ** * ** ***


```
public final class Depth
```

<br />

*** ** * ** ***

Depth information corresponding to a specific `https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint`.

The availability of depth data depends on the `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode`. Depth Maps can include smooth, `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#SMOOTH_ONLY()`, raw, `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#RAW_ONLY()`, or both, `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#SMOOTH_AND_RAW()`, postprocessing options depending on the runtime.

This also allows depth to be turned off by setting it to `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#DISABLED()`.

The mode is set in a `https://developer.android.com/reference/androidx/xr/runtime/Session#config()` that is passed to `https://developer.android.com/reference/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)`.

Update frequency and the dimensions of the maps provided are system-defined. The buffer lifecycles are controlled by the runtime so if the data will not be used upon receiving, a copy should be made.

OpenXr does not support `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#SMOOTH_AND_RAW()`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/xr/arcore/Depth.State` Contains the current state of depth tracking. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Depth.State>` | `https://developer.android.com/reference/androidx/xr/arcore/Depth#getState()()` the current `https://developer.android.com/reference/androidx/xr/arcore/Depth.State` of the depth data |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Depth` | `https://developer.android.com/reference/androidx/xr/arcore/Depth#left(androidx.xr.runtime.Session)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session)` Returns the Depth data associated with the left display. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Depth` | `https://developer.android.com/reference/androidx/xr/arcore/Depth#mono(androidx.xr.runtime.Session)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session)` Returns the Depth associated with the single device display. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Depth` | `https://developer.android.com/reference/androidx/xr/arcore/Depth#right(androidx.xr.runtime.Session)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session)` Returns the Depth data associated with the right display. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/xr/arcore/Depth#toString()()` Returns a string representation of `https://developer.android.com/reference/androidx/xr/arcore/Depth` for debugging. |

## Public methods

### getState

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
public final @NonNull StateFlow<@NonNull Depth.State> getState()
```

the current `https://developer.android.com/reference/androidx/xr/arcore/Depth.State` of the depth data

### left

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
public static final @NonNull Depth left(@NonNull Session session)
```

Returns the Depth data associated with the left display.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | the currently active `https://developer.android.com/reference/androidx/xr/runtime/Session` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `https://developer.android.com/reference/androidx/xr/runtime/Config#depthEstimation()` is set to `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#DISABLED()` or if the device does not support `https://developer.android.com/reference/androidx/xr/runtime/RenderingMode#STEREO()` |

### mono

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
public static final @NonNull Depth mono(@NonNull Session session)
```

Returns the Depth associated with the single device display.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | the currently active `https://developer.android.com/reference/androidx/xr/runtime/Session` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `https://developer.android.com/reference/androidx/xr/runtime/Session#config()` has `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode` set to DISABLED or if device does not support `https://developer.android.com/reference/androidx/xr/runtime/RenderingMode#MONO()` |

### right

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
public static final @NonNull Depth right(@NonNull Session session)
```

Returns the Depth data associated with the right display.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | the currently active `https://developer.android.com/reference/androidx/xr/runtime/Session` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `https://developer.android.com/reference/androidx/xr/runtime/Config#depthEstimation()` is set to `https://developer.android.com/reference/androidx/xr/runtime/DepthEstimationMode#DISABLED()` or if the device does not support `https://developer.android.com/reference/androidx/xr/runtime/RenderingMode#STEREO()` |

### toString

```
public @NonNull String toString()
```

Returns a string representation of `https://developer.android.com/reference/androidx/xr/arcore/Depth` for debugging.

Note: Not intended for production use.