ImgFrame 和 Transformable 消息相互对齐。这两种类型都可以作为源或对齐目标,包括将 ImgFrame 对齐到任何可转换消息类型。Align 默认在 RVC4 设备上运行,也可以在主机上运行。自定义消息对齐需要主机执行并覆盖 transformTo()。如何放置
Python
Python
1with dai.Pipeline() as pipeline:
2 align = pipeline.create(dai.node.Align)输入和输出
input: 要转换的消息。inputAlignTo: 其ImgTransformation定义目标坐标系的消息。inputConfig: 接受AlignConfig消息以在运行时更新对齐设置。使用initialConfig在启动管道之前配置节点。outputAligned: 对齐后的消息,类型与input上的消息相同。passthroughInput: 用于对齐的原始输入消息。
工作原理
ImgTransformation 元数据将源映射到目标坐标系。源和目标不需要具有相同的消息类型。例如,您可以将检测对齐到图像,将图像对齐到检测,或将两个可转换消息相互对齐。对于 ImgDetections,这允许您将神经网络输入图像中的检测映射到调整大小、裁剪、旋转或去畸变的图像以进行显示。用法
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()ImgDetections 消息。要将图像对齐到检测,请交换连接到 input 和 inputAlignTo 的流;对齐后的输出将包含 ImgFrame 消息。自定义消息
TransformableBuffer 并覆盖 transformTo(target) 以返回转换后的副本。将源 ImgTransformation 附加到每条消息,在 transformTo() 中转换其自定义字段,并设置返回消息的目标转换。在启动管道之前将 Align 设置为在主机上运行:Python
Python
1align.setRunOnHost(True)transformTo() 以将这些端点重新映射到目标图像的坐标系中。功能示例
参考
class
dai::node::Align
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)需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。