此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 如何放置
  • 输入和输出
  • 工作原理
  • 用法
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
Supported on:RVC2RVC4
ImageAlign 节点用于对齐传感器帧,例如将深度图(来自 ToF/Stereo)对齐到彩色帧(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)

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。