# image_align_depth_correction

Python API: `depthai_nodes.node.image_align_depth_correction`

Shared RGB target-axial correction between ImageAlign and PointCloud.

## Classes

| Name | Description |
| --- | --- |
| [`ImageAlignDepthCorrection`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection) | Convert aligned source-camera axial Z into target-camera axial depth. |

### class `ImageAlignDepthCorrection`

```python
class ImageAlignDepthCorrection(dai.node.ThreadedHostNode)
```

Convert aligned source-camera axial Z into target-camera axial depth.

Connect `outputAligned` and the exact `passthroughInput` from one ImageAlign node. Both bounded blocking inputs must remain
lossless. Sequence number, host timestamp and device timestamp must match exactly. A mismatched pair fails visibly. Missing inputs
block until messages arrive, so keep both streams lossless. Preserve unique occurrence sequence numbers when replaying. ImageAlign
owns the target-image match, so no third image input is needed.

The aligned frame's `ImgTransformation` describes the actual target grid. It must be an undistorted perspective grid. The source
passthrough must retain the depth optical frame's actual calibration and rectification; a native left image cannot substitute for
rectified depth metadata. Branch RGB undistortion before alignment when needed, retaining separate native image streams for
detection. Source and target calibration references, sizes, intrinsics, rigid poses and RAW16 layouts are checked per frame.

Select `policy` explicitly in `build()`. Use `AxialDepthPolicy.SOURCE_AXIAL_REQUIRES_CORRECTION` for the source-Z ImageAlign
behavior verified with DepthAI 3.12.0. Use `AxialDepthPolicy.TARGET_AXIAL_PASSTHROUGH` only for a producer verified to already
provide target-camera Z. There is no SDK-version heuristic. Recheck the producer's behavior when upgrading the SDK.

`out` emits an independent native RAW16 `ImgFrame` in target-camera axial millimeters for PointCloud. `result` emits an
`AxialDepthFrameResult` containing that frame and its provenance. Use `result.provenance.to_dict()` for reports. Geometry
identity, axial conventions, correction method, invalid-value/quantization rules and source association are retained. The
structured result stays in one Python runtime, including an OAK-4 app's CPU. XLink, RemoteConnection and native frame cloning do
not retain its Python fields. Keep the matching result or sidecar at later correction boundaries. Structured results reject double
conversion; an unmarked bare native frame cannot reveal its earlier conversion history.

Conversion uses float64 arithmetic and nearest-integer millimeter rounding with ties to even. Depth 0 and 65535 remain invalid;
nonfinite, nonpositive or out-of-range conversions become zero. Input buffers remain unchanged. The cloned output preserves target
transformation, source metadata, timing, sequence, active-plane offset, row stride and padding. PointCloud consumers still need to
exclude both invalid depths and nonfinite points, preserve raster order when filtering, and select the intended millimeter
coordinate frame explicitly.

This Python node runs on the workstation in a host pipeline or on the OAK-4 application CPU in a standalone app. It does not
require an implicit device. The repository's `examples/image_align_depth_correction` fixture verifies alignment and corrected
cloud geometry on the host or OAK-4. Its synthetic result does not establish live NeuralDepth accuracy or throughput. For
array-based correction and explicit previous provenance, use `depthai_nodes.utils.axial_depth.AxialDepthCorrector`.

> **Example**
> With configured ImageAlign and PointCloud nodes:

```text
from depthai_nodes.node import ImageAlignDepthCorrection
from depthai_nodes.utils.axial_depth import AxialDepthPolicy

correction = pipeline.create(ImageAlignDepthCorrection).build(
    align.outputAligned,
    align.passthroughInput,
    policy=AxialDepthPolicy.SOURCE_AXIAL_REQUIRES_CORRECTION,
)
correction.out.link(cloud.inputDepth)
provenance = correction.result.createOutputQueue()
```

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection-out) | `dai.Node.Output` | Native target-axial RAW16 millimeters for PointCloud. |
| [`result`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection-result) | `dai.Node.Output` | Associated frame and provenance for consumers in the same Python runtime. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection-__init__) |  |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection-build) | Connect the aligned output and exact source passthrough of one ImageAlign. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/image_align_depth_correction.md#image_align_depth_correction-Classes-ImageAlignDepthCorrection-run) | Process lossless source-associated pairs with bounded queue backpressure. |

#### property `out`

```python
out: dai.Node.Output
```

Native target-axial RAW16 millimeters for PointCloud.

#### property `result`

```python
result: dai.Node.Output
```

Associated frame and provenance for consumers in the same Python runtime.

#### method `__init__`

```python
def __init__()
```

#### method `build`

```python
def build(
    alignedDepth: dai.Node.Output,
    sourceDepth: dai.Node.Output,
    *,
    policy: AxialDepthPolicy | str,
) -> ImageAlignDepthCorrection
```

Connect the aligned output and exact source passthrough of one ImageAlign.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `alignedDepth` | `dai.Node.Output` | ImageAlign `outputAligned` on an undistorted target grid. | required |
| `sourceDepth` | `dai.Node.Output` | The same ImageAlign node's `passthroughInput`. | required |
| `policy` | `AxialDepthPolicy | str` | Explicit correction or target-axial passthrough declaration. | required |

Returns

| Type | Description |
| --- | --- |
| `ImageAlignDepthCorrection` | This configured node. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If policy or stream ownership is invalid. |
| `RuntimeError` | If already built. |

#### method `run`

```python
def run()
```

Process lossless source-associated pairs with bounded queue backpressure.
