# ImageAlign

ImageAlign 节点用于将传感器帧与设备上的任何其他传感器帧对齐，包括 ToF 传感器。它还可以将两个传感器与静态深度对齐，使其对热成像-RGB 对齐非常有用。

## 如何放置它

#### Python

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

#### C++

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

## 输入和输出

## 工作原理

ImageAlign 节点接受两个输入：inputAlignTo 和 input。inputAlignTo 是 input 帧将要对齐到的帧。input 帧将与 inputAlignTo 帧对齐，对齐后的帧被发送到 outputAligned
输出。inputAlignTo 只读取一次以提取帧元数据，然后 input 帧根据两个传感器之间的外部标定进行重投影并对齐到该元数据。

## 用法

#### Python

```python
pipeline = dai.Pipeline()

rgb_cam = pipeline.create(dai.node.ColorCamera)
# 假设 RGB 相机传感器在端口 CAM_A 上
rgb_cam.setBoardSocket(dai.CameraBoardSocket.CAM_A)

tof = pipeline.create(dai.node.ToF)
# 假设 ToF 相机传感器在端口 CAM_B 上
tof_cam.setBoardSocket(dai.CameraBoardSocket.CAM_B)

image_align = pipeline.create(dai.node.ImageAlign)
# 将来自 ToF 的深度对齐到 RGB
tof.depth.link(image_align.input)
rgb_cam.video.link(image_align.inputAlignTo)

# 将对齐后的输出发送到主机
image_align.outputAligned.link(xout.input)
```

#### C++

```cpp
dai::Pipeline pipeline;

auto rgbCam = pipeline.create<dai::node::ColorCamera>();
// 假设 RGB 相机传感器在端口 CAM_A 上
rgbCam->setBoardSocket(dai::CameraBoardSocket::CAM_A);

auto tof = pipeline.create<dai::node::ToF>();
// 假设 ToF 相机传感器在端口 CAM_B 上
tofCam->setBoardSocket(dai::CameraBoardSocket::CAM_B);

auto imageAlign = pipeline.create<dai::node::ImageAlign>();
// 将来自 ToF 的深度对齐到 RGB
tof->depth.link(imageAlign->input);
rgbCam->video.link(imageAlign->inputAlignTo);

auto xout = pipeline.create<dai::node::XLinkOut>();
xout->setStreamName("aligned");
// 将对齐后的输出发送到主机
imageAlign->outputAligned.link(xout->input);
```

## 功能示例

 * [对齐单色和彩色相机](https://docs.luxonis.com/software/depthai/examples/image_align.md)
 * [热成像-RGB 对齐](https://docs.luxonis.com/software/depthai/examples/thermal_align.md)
 * [ToF-RGB 对齐](https://docs.luxonis.com/software/depthai/examples/tof_align.md)

## 参考

### 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.

### 需要帮助？

请前往 [OAKChina 官网](https://www.oakchina.cn/) 获取技术支持或解答您的任何疑问。
