本页目录

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

AprilTag

Supported on:RVC2RVC4
AprilTag 节点接收 ImgFrame 作为输入,并输出检测到的 AprilTag 标记(AprilTags 消息)。它基于 AprilRobotics/apriltag 仓库,并在 CPU 上运行优化后的检测算法(在 RVC4 八核设备上本地运行,或者在基于 RVC2 的设备上运行于主机端)。AprilTag 标记是一种视觉 fiducial marker,因此与 ArUco、ARTag 和 ARToolKit 标记类似。

如何放置

Python

Python
1pipeline = dai.Pipeline()
2hostCamera = pipeline.create(dai.node.Camera).build()
3aprilTagNode = pipeline.create(dai.node.AprilTag)
4# Link 1920x1080 output to AprilTag input
5hostCamera.requestOutput((1920, 1080)).link(aprilTagNode.inputImage)
6# Create output queue for passthrough frames
7passthroughOutputQueue = aprilTagNode.passthroughInputImage.createOutputQueue()
8# Create output queue for detected 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// Link 1920x1080 output to AprilTag input
5auto outputCam = cameraNode->requestOutput(std::make_pair(1920, 1080));
6outputCam->link(aprilTagNode->inputImage);
7// Create output queue for passthrough frames
8auto passthroughOutputQueue = aprilTagNode->passthroughInputImage.createOutputQueue();
9// Create output queue for detected AprilTags
10auto outQueue = aprilTagNode->out.createOutputQueue();

输入和输出

限制

RVC2

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

RVC4

RVC4 可以处理 1080P 帧190FPS,同时占用 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)

需要帮助?

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