本页目录

  • 如何放置
  • 输入与输出
  • 工作原理
  • 用法
  • 功能示例
  • 参考

ImageAlign

Supported on:RVC2RVC4
ImageAlign 节点 用于对齐传感器帧,例如将深度图(来自 ToF/立体视觉)对齐到彩色帧(RGB-D),或在指定深度平面时将温度/热成像帧对齐到彩色帧(RGB-Thermal)。

如何放置

Python

Python
1with dai.Pipeline() as pipeline:
2    img_align = pipeline.create(dai.node.ImageAlign)

C++

C++
1dai::Pipeline pipeline;
2auto align = pipeline.create<dai::node::ImageAlign>();

输入与输出

工作原理

ImageAlign 将 input 帧对齐到 inputAlignTo 帧。inputAlignTo 仅被读取一次以提取帧元数据,然后根据两个传感器之间的外参标定,对 input 帧进行重投影并对齐。

用法

Python

Python
1with dai.Pipeline() as pipeline:
2    rgb_cam = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
3    video_stream = rgb_cam.requestOutput(size=(1280, 960))
4
5    # 创建左/右立体相机及 StereoDepth 节点
6    left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
7    right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
8    stereo = pipeline.create(dai.node.StereoDepth)
9
10    left.requestOutput(size=(640, 400)).link(stereo.left)
11    right.requestOutput(size=(640, 400)).link(stereo.right)
12
13    # 创建 ImageAlign 节点并将立体深度对齐到 RGB 流
14    img_align = pipeline.create(dai.node.ImageAlign)
15    stereo.depth.link(align.input)
16    video_stream.link(align.inputAlignTo)
17
18    # 如果需要同步对齐后的深度和彩色流,可以使用 Sync 节点
19    sync = pipeline.create(dai.node.Sync)
20    img_align.outputAligned.link(sync.inputs['aligned_depth'])
21    video_stream.link(sync.inputs["color"])
22
23    # 创建输出队列,以便将同步帧传送到主机
24    queue = sync.out.createOutputQueue()
25
26    # ...

C++

C++
1dai::Pipeline pipeline;
2
3// 创建 RGB 相机
4auto rgbCam = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);
5auto videoStream = rgbCam->requestOutput({1280, 960});
6
7// 创建左、右立体相机
8auto left = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_B);
9auto right = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_C);
10auto stereo = pipeline.create<dai::node::StereoDepth>();
11
12left->requestOutput({640, 400})->link(stereo->left);
13right->requestOutput({640, 400})->link(stereo->right);
14
15// 创建 ImageAlign 节点
16auto imgAlign = pipeline.create<dai::node::ImageAlign>();
17stereo->depth.link(imgAlign->input);
18videoStream.link(imgAlign->inputAlignTo);
19
20// 创建 Sync 节点
21auto sync = pipeline.create<dai::node::Sync>();
22imgAlign->outputAligned.link(sync->inputs["aligned_depth"]);
23videoStream.link(sync->inputs["color"]);
24
25// 创建输出队列
26auto queue = sync->out.createOutputQueue();
27// ...

功能示例

参考

class

dai::node::ImageAlign

#include ImageAlign.hpp
variable
std::shared_ptr< ImageAlignConfig > initialConfig
Initial config to use when calculating spatial location data.
variable
Input inputConfig
Input message with ability to modify parameters in runtime. Default queue is non-blocking with size 4.
variable
Input input
Input message. Default queue is non-blocking with size 4.
variable
Input inputAlignTo
Input align to message. Default queue is non-blocking with size 1.
variable
Output outputAligned
Outputs ImgFrame message that is aligned to inputAlignTo.
variable
Output passthroughInput
Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.
function
ImageAlign & setOutputSize(int alignWidth, int alignHeight)
Specify the output size of the aligned image
function
ImageAlign & setOutKeepAspectRatio(bool keep)
Specify whether to keep aspect ratio when resizing
function
ImageAlign & setInterpolation(Interpolation interp)
Specify interpolation method to use when resizing
function
ImageAlign & setNumShaves(int numShaves)
Specify number of shaves to use for this node
function
ImageAlign & setNumFramesPool(int numFramesPool)
Specify number of frames in the pool
function
void setRunOnHost(bool runOnHost)
Specify whether to run on host or device By default, the node will run on device.
function
bool runOnHost()
Check if the node is set to run on host
function
void run()
inline function
DeviceNodeCRTP()
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)
inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)
inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

需要帮助?

请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。