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

本页目录

  • 如何放置
  • 输入和输出
  • 工作原理
  • 用法
  • 自定义消息
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
Supported on:RVC4
Align 节点提供了一种通用方法,用于将 ImgFrame 和 Transformable 消息相互对齐。这两种类型都可以作为源或对齐目标,包括将 ImgFrame 对齐到任何可转换消息类型。Align 默认在 RVC4 设备上运行,也可以在主机上运行。自定义消息对齐需要主机执行并覆盖 transformTo()。

如何放置

Python

Python
1with dai.Pipeline() as pipeline:
2    align = pipeline.create(dai.node.Align)

C++

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

输入和输出

  • input: 要转换的消息。
  • inputAlignTo: 其 ImgTransformation 定义目标坐标系的消息。
  • inputConfig: 接受 AlignConfig 消息以在运行时更新对齐设置。使用 initialConfig 在启动管道之前配置节点。
  • outputAligned: 对齐后的消息,类型与 input 上的消息相同。
  • passthroughInput: 用于对齐的原始输入消息。

工作原理

Align 使用源消息和目标消息携带的 ImgTransformation 元数据将源映射到目标坐标系。源和目标不需要具有相同的消息类型。例如,您可以将检测对齐到图像,将图像对齐到检测,或将两个可转换消息相互对齐。对于 ImgDetections,这允许您将神经网络输入图像中的检测映射到调整大小、裁剪、旋转或去畸变的图像以进行显示。

用法

要将检测对齐到图像,请将现有 DetectionNetwork 的输出连接到 input,并将目标图像流连接到 inputAlignTo。在此代码片段中,manip 是一个现有的 ImageManip 节点,它生成目标图像。

Python

Python
1align = pipeline.create(dai.node.Align)
2detectionNetwork.out.link(align.input)
3manip.out.link(align.inputAlignTo)
4
5alignedDetectionsQueue = align.outputAligned.createOutputQueue()

C++

C++
1auto align = pipeline.create<dai::node::Align>();
2detectionNetwork->out.link(align->input);
3manip->out.link(align->inputAlignTo);
4
5auto alignedDetectionsQueue = align->outputAligned.createOutputQueue();
输出队列包含目标图像坐标系中的 ImgDetections 消息。要将图像对齐到检测,请交换连接到 input 和 inputAlignTo 的流;对齐后的输出将包含 ImgFrame 消息。

自定义消息

自定义消息可以派生自 TransformableBuffer 并覆盖 transformTo(target) 以返回转换后的副本。将源 ImgTransformation 附加到每条消息,在 transformTo() 中转换其自定义字段,并设置返回消息的目标转换。在启动管道之前将 Align 设置为在主机上运行:

Python

Python
1align.setRunOnHost(True)

C++

C++
1align->setRunOnHost(true);
下面的自定义消息示例定义了一条具有两个端点的线,并覆盖 transformTo() 以将这些端点重新映射到目标图像的坐标系中。

功能示例

示例PythonC++
将 ImgDetections 对齐到转换后的图像Python 示例C++ 示例
在主机上对齐自定义消息Python 示例C++ 示例

参考

class

dai::node::Align

#include Align.hpp
variable
std::shared_ptr< AlignConfig > initialConfig
Initial config to use when aligning messages.
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 to be aligned. Can be either ImgFrame or any message that implements Transformable interface. 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 the input message aligned to the inputAlignTo message. Output message will be of the same type as input message.
variable
Output passthroughInput
Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.
function
Align & 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()
function
void buildStage1()
Build stages;.
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)

需要帮助?

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