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

本页目录

  • 如何放置它
  • 输入和输出
  • 限制
  • 功能示例
  • 参考

AprilTag

Supported on:RVC2RVC4
AprilTag 节点以 ImgFrame 作为输入,并输出检测到的 AprilTag 标记(AprilTags 消息)。它基于 AprilRobotics/apriltag 存储库,并在 CPU 上运行优化的检测算法(在 RVC4 八核本身,或在使用基于 RVC2 的设备时在主机上运行)。AprilTag 标记是一种视觉 定位标记,因此它类似于 ArUco、ARTag 和 ARToolKit 标记。

如何放置它

Python

Python
1pipeline = dai.Pipeline()
2hostCamera = pipeline.create(dai.node.Camera).build()
3aprilTagNode = pipeline.create(dai.node.AprilTag)
4# 将 1920x1080 输出链接到 AprilTag 输入
5hostCamera.requestOutput((1920, 1080)).link(aprilTagNode.inputImage)
6# 为直通帧创建输出队列
7passthroughOutputQueue = aprilTagNode.passthroughInputImage.createOutputQueue()
8# 为检测到的 AprilTags 创建输出队列
9outQueue = aprilTagNode.out.createOutputQueue()

C++

C++
1dai::Pipeline pipeline;
2auto cameraNode = pipeline.create<dai::node::Camera>()->build();
3auto aprilTagNode = pipeline.create<dai::node::AprilTag>();
4// 将 1920x1080 输出链接到 AprilTag 输入
5auto outputCam = cameraNode->requestOutput(std::make_pair(1920, 1080));
6outputCam->link(aprilTagNode->inputImage);
7// 为直通帧创建输出队列
8auto passthroughOutputQueue = aprilTagNode->passthroughInputImage.createOutputQueue();
9// 为检测到的 AprilTags 创建输出队列
10auto outQueue = aprilTagNode->out.createOutputQueue();

输入和输出

限制

RVC2

RVC2 设备上,AprilTag 节点在主机上运行,因此性能将受限于主机 CPU。

RVC4

RVC4 可以大约以 190FPS 的速度处理 1080P 帧,同时消耗 25% 的 CPU。我们使用 此脚本 来基准测试性能, 以下是结果:
Command Line
1[441340706] [10.12.101.114] [1725552371.591] [BenchmarkIn(3)] [warning] FPS: 191.80461
2[441340706] [10.12.101.114] [1725552371.592] [BenchmarkIn(3)] [warning] Messages took 52.13639 s
3[441340706] [10.12.101.114] [1725552371.593] [BenchmarkIn(3)] [warning] Average latency is 0 s

功能示例

参考

class

dai::node::AprilTag

#include AprilTag.hpp
variable
std::shared_ptr< AprilTagConfig > initialConfig
Initial config to use when calculating spatial location data.
variable
Input inputConfig
Input AprilTagConfig message with ability to modify parameters in runtime. Default queue is non-blocking with size 4.
variable
Input inputImage
Input message with depth data used to retrieve spatial information about detected object. Default queue is non-blocking with size 4.
variable
Output out
Outputs AprilTags message that carries spatial location results.
variable
Output outConfig
Outputs AprilTagConfig message that contains current configuration.
variable
Output passthroughInputImage
Passthrough message on which the calculation was performed. Suitable for when input queue is set to non-blocking behavior.
function
AprilTag()
function
AprilTag(std::unique_ptr< Properties > props)
function
void setWaitForConfigInput(bool wait)
Specify whether or not wait until configuration message arrives to inputConfig Input.
Parameters
  • wait: True to wait for configuration message, false otherwise.
function
bool getWaitForConfigInput()
function
void setNumThreads(int numThreads)
Set number of threads to use for AprilTag detection.
Parameters
  • numThreads: Number of threads to use.
function
int getNumThreads()
Get number of threads to use for AprilTag detection.
Returns
Number of threads to use.
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 buildInternal()
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)

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。