# ImageAlign

ImageAlign node is used for aligning sensor frames to any other sensor frame on the device, including ToF sensors. It can also
align two sensors with a static depth, making it useful for thermal-RGB alignment.

## How to place it

#### Python

```python
pipeline = dai.Pipeline()
align = pipeline.create(dai.node.ImageAlign)
```

#### C++

```cpp
dai::Pipeline pipeline;
auto align = pipeline.create<dai::node::ImageAlign>();
```

## Inputs and Outputs

## How it works

The `ImageAlign` node takes two inputs: `inputAlignTo` and `input`. The `inputAlignTo` is the frame to which the `input` frame
will be aligned. The `input` frame will be aligned to the `inputAlignTo` frame and the aligned frame will be sent to the
`outputAligned` output. The `inputAlignTo` is only read once to extract the frame metadata, then the `input` frame is reprojected
and aligned to it based on the extrinsic calibration between the two sensors.

## Usage

#### Python

```python
pipeline = dai.Pipeline()

rgb_cam = pipeline.create(dai.node.ColorCamera)
# Assume the RGB camera sensor is on port CAM_A
rgb_cam.setBoardSocket(dai.CameraBoardSocket.CAM_A)

tof = pipeline.create(dai.node.ToF)
# Assume the ToF camera sensor is on port CAM_B
tof_cam.setBoardSocket(dai.CameraBoardSocket.CAM_B)

image_align = pipeline.create(dai.node.ImageAlign)
# Align depth from ToF to RGB
tof.depth.link(image_align.input)
rgb_cam.video.link(image_align.inputAlignTo)

# Send aligned output to the host
image_align.outputAligned.link(xout.input)
```

#### C++

```cpp
dai::Pipeline pipeline;

auto rgbCam = pipeline.create<dai::node::ColorCamera>();
// Assume the RGB camera sensor is on port CAM_A
rgbCam->setBoardSocket(dai::CameraBoardSocket::CAM_A);

auto tof = pipeline.create<dai::node::ToF>();
// Assume the ToF camera sensor is on port CAM_B
tofCam->setBoardSocket(dai::CameraBoardSocket::CAM_B);

auto imageAlign = pipeline.create<dai::node::ImageAlign>();
// Align depth from ToF to RGB
tof->depth.link(imageAlign->input);
rgbCam->video.link(imageAlign->inputAlignTo);

auto xout = pipeline.create<dai::node::XLinkOut>();
xout->setStreamName("aligned");
// Send aligned output to the host
imageAlign->outputAligned.link(xout->input);
```

## Examples of functionality

 * [Aligning mono and color cameras](https://docs.luxonis.com/software/depthai/examples/image_align.md)
 * [Thermal-RGB alignment](https://docs.luxonis.com/software/depthai/examples/thermal_align.md)
 * [ToF-RGB alignment](https://docs.luxonis.com/software/depthai/examples/tof_align.md)

## Reference

### depthai.node.ImageAlign(depthai.Node)

Kind: Class

ImageAlign node. Calculates spatial location data on a set of ROIs on depth map.

#### setInterpolation(self, arg0: depthai.Interpolation) -> ImageAlign: ImageAlign

Kind: Method

Specify interpolation method to use when resizing

#### setNumFramesPool(self, arg0: typing.SupportsInt) -> ImageAlign: ImageAlign

Kind: Method

Specify number of frames in the pool

#### setNumShaves(self, arg0: typing.SupportsInt) -> ImageAlign: ImageAlign

Kind: Method

Specify number of shaves to use for this node

#### setOutKeepAspectRatio(self, arg0: bool) -> ImageAlign: ImageAlign

Kind: Method

Specify whether to keep aspect ratio when resizing

#### setOutputSize(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> ImageAlign: ImageAlign

Kind: Method

Specify the output size of the aligned image

#### initialConfig

Kind: Property

Initial config to use when calculating spatial location data.

#### input

Kind: Property

Input message. Default queue is non-blocking with size 4.

#### inputAlignTo

Kind: Property

Input align to message. Default queue is non-blocking with size 1.

#### inputConfig

Kind: Property

Input message with ability to modify parameters in runtime. Default queue is
non-blocking with size 4.

#### outputAligned

Kind: Property

Outputs ImgFrame message that is aligned to inputAlignTo.

#### passthroughInput

Kind: Property

Passthrough message on which the calculation was performed. Suitable for when
input queue is set to non-blocking behavior.

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
