# axial_depth

Python API: `depthai_nodes.utils.axial_depth`

Convert ImageAlign source-camera axial millimeters to target-camera axial depth.

ImageAlign places source Z on target pixels. For an undistorted target ray `r` and `T_source_target = [R | t]`, the required
target Z is `(Z_source - t[2]) / (R[2] dot r)`. Rectified source depth must carry its actual virtual-camera pose. Native
source-camera calibration is not a substitute.

## Classes

| Name | Description |
| --- | --- |
| [`AxialDepthCorrector`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthCorrector) | Correct aligned axial Z with a bounded per-instance geometry cache. |
| [`AxialDepthGeometry`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthGeometry) | Immutable geometry for aligned target pixels and source optical Z. |
| [`AxialDepthPolicy`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthPolicy) | Explicit declaration of the upstream SDK's axial depth convention. |
| [`AxialDepthProvenance`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthProvenance) | JSON-reportable correction policy, geometry, validity, and association. |
| [`AxialDepthResult`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthResult) | Independent target-grid uint16 millimeters and their axial provenance. |

### class `AxialDepthCorrector`

```python
class AxialDepthCorrector
```

Correct aligned axial Z with a bounded per-instance geometry cache.

Native frames have no durable arbitrary provenance fields. Retain a returned `AxialDepthFrameResult` or supply its provenance when
crossing this API again.

Args

| Name | Description |
| --- | --- |
| `policy` | Explicit source correction or already-target-axial passthrough. |
| `cache_entries` | Maximum cached denominator grids. Zero disables caching. |
| `cache_bytes` | Maximum bytes retained by cached denominator grids. |

Attributes

| Name | Description |
| --- | --- |
| `cache_bytes` |  |
| `cache_entries` |  |
| `policy` |  |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthCorrector-__init__) |  |
| [`correct`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthCorrector-correct) | Convert a uint16 target-grid array, or explicitly pass target Z through. |
| [`correct_frame`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthCorrector-correct_frame) | Return independent RAW16 bytes while preserving all aligned native metadata. |

#### method `__init__`

```python
def __init__(
    *,
    policy: AxialDepthPolicy | str,
    cache_entries: int = 4,
    cache_bytes: int = 64 * 1024 * 1024,
)
```

#### method `correct`

```python
def correct(
    depth: np.ndarray | AxialDepthResult,
    geometry: AxialDepthGeometry,
    *,
    previous_provenance: AxialDepthProvenance | Mapping | None = None,
) -> AxialDepthResult
```

Convert a uint16 target-grid array, or explicitly pass target Z through.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `depth` | `np.ndarray | AxialDepthResult` | Aligned source axial millimeters, or a previous associated result. | required |
| `geometry` | `AxialDepthGeometry` | Actual source optical pose and undistorted target pixel geometry. | required |
| `previous_provenance` | `AxialDepthProvenance | Mapping | None` | Retained provenance when passing a bare array again. | `None` |

Returns

| Type | Description |
| --- | --- |
| `AxialDepthResult` | Independent uint16 array and reportable provenance. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If geometry, shape, or an explicit prior target-Z mark conflicts. |
| `TypeError` | If depth is not a two-dimensional uint16 array. |

#### method `correct_frame`

```python
def correct_frame(
    aligned_frame: dai.ImgFrame | AxialDepthFrameResult,
    source_frame: dai.ImgFrame,
    *,
    previous_provenance: AxialDepthProvenance | Mapping | None = None,
) -> AxialDepthFrameResult
```

Return independent RAW16 bytes while preserving all aligned native metadata.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `aligned_frame` | `dai.ImgFrame | AxialDepthFrameResult` | Native aligned depth or a prior associated result. | required |
| `source_frame` | `dai.ImgFrame` | Exact ImageAlign source passthrough, with actual depth geometry. | required |
| `previous_provenance` | `AxialDepthProvenance | Mapping | None` | Retained mark when passing a native frame again. | `None` |

Returns

| Type | Description |
| --- | --- |
| `AxialDepthFrameResult` | Native frame and provenance in one same-runtime message. |

### class `AxialDepthGeometry`

```python
class AxialDepthGeometry(_GeometryValues)
```

Immutable geometry for aligned target pixels and source optical Z.

Attributes

| Name | Description |
| --- | --- |
| `identity` | Additional immutable geometry identity. `geometry_from_frames` includes both complete image transformations and calibration references. |
| `source_from_target_mm` | Rigid transform from target optical coordinates into the actual source depth optical frame, including rectification. |
| `target_intrinsics` | Intrinsics of the undistorted target pixel grid. |
| `target_size` | Actual aligned target width and height. |

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`digest`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthGeometry-digest) | `str` | SHA-256 of all computational geometry and supplied calibration identity. |

#### property `digest`

```python
digest: str
```

SHA-256 of all computational geometry and supplied calibration identity.

### class `AxialDepthPolicy`

```python
class AxialDepthPolicy(str, Enum)
```

Explicit declaration of the upstream SDK's axial depth convention.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `SOURCE_AXIAL_REQUIRES_CORRECTION` | `str` |  |
| `TARGET_AXIAL_PASSTHROUGH` | `str` |  |

### class `AxialDepthProvenance`

```python
class AxialDepthProvenance
```

JSON-reportable correction policy, geometry, validity, and association.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `aligned_association` | `tuple[tuple[str, int], ...]` |  |
| `correction_enabled` | `bool` |  |
| `correction_method` | `str` |  |
| `geometry_digest` | `str` |  |
| `input_axial_convention` | `str` |  |
| `invalid_policy` | `str` |  |
| `output_axial_convention` | `str` |  |
| `policy` | `str` |  |
| `quantization` | `str` |  |
| `rejected_valid_source_pixels` | `int` |  |
| `source_association` | `tuple[tuple[str, int], ...]` |  |
| `units` | `str` |  |

Methods

| Name | Description |
| --- | --- |
| [`to_dict`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Classes-AxialDepthProvenance-to_dict) | Return JSON-serializable provenance for a benchmark or production report. |

#### method `to_dict`

```python
def to_dict() -> dict
```

Return JSON-serializable provenance for a benchmark or production report.

### class `AxialDepthResult`

```python
class AxialDepthResult
```

Independent target-grid uint16 millimeters and their axial provenance.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `depth` | `np.ndarray` |  |
| `provenance` | `AxialDepthProvenance` |  |

## Functions

| Name | Description |
| --- | --- |
| [`geometry_from_frames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/utils/axial_depth.md#axial_depth-Functions-geometry_from_frames) | Validate exact source association and recover actual optical geometry. |

### function `geometry_from_frames`

```python
def geometry_from_frames(
    aligned_frame: dai.ImgFrame,
    source_frame: dai.ImgFrame,
) -> AxialDepthGeometry
```

Validate exact source association and recover actual optical geometry.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `aligned_frame` | `dai.ImgFrame` | ImageAlign output on an undistorted perspective target grid. | required |
| `source_frame` | `dai.ImgFrame` | Corresponding ImageAlign `passthroughInput`, including the source depth's virtual rectified pose. | required |

Returns

| Type | Description |
| --- | --- |
| `AxialDepthGeometry` | Immutable geometry keyed by both full transformations. |

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If either frame is not RAW16. |
| `ValueError` | If layout, association, calibration, or target projection is invalid. |
