DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 如何放置它
  • 输入和输出
  • 零项跟踪
  • 短期跟踪
  • 支持的对象跟踪器类型
  • 最大跟踪对象数
  • 用法
  • 功能示例
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

ObjectTracker

最后更新
Object tracker 使用卡尔曼滤波器和匈牙利算法跟踪 ImgDetections 中检测到的对象。

如何放置它

Python

Python
1pipeline = dai.Pipeline()
2objectTracker = pipeline.create(dai.node.ObjectTracker)

C++

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

输入和输出

零项跟踪

零项跟踪执行对象关联,这意味着它不基于先前的跟踪历史进行预测和跟踪。 对象关联意味着将外部检测器检测到的对象与从先前帧检测并正在跟踪的对象进行映射。

短期跟踪

短期跟踪允许在帧之间跟踪对象,从而减少在每个帧上运行对象检测的需要。这对于无法达到 30FPS 的 NN 模型(例如 YoloV5)非常有效;当没有推理时,跟踪器可以提供跟踪轨迹,因此整个系统可以以 30FPS 运行。

支持的对象跟踪器类型

  • SHORT_TERM_KCF:核相关滤波器跟踪。KCF 利用循环矩阵的特性来提高处理速度。论文 此处。
  • SHORT_TERM_IMAGELESS:短期跟踪允许在跳过对象检测的帧上跟踪对象,通过从先前的检测中推断对象轨迹。
  • ZERO_TERM_COLOR_HISTOGRAM:利用位置、形状和输入图像信息(如 RGB 直方图)执行对象跟踪。
  • ZERO_TERM_IMAGELESS:仅利用检测对象的矩形形状和位置信息进行对象跟踪。它不使用跟踪对象的颜色信息。它比 ZERO_TERM_COLOR_HISTOGRAM 具有更高的吞吐量。用户在选择对象跟踪器类型时需要权衡吞吐量和准确性。
有关对象跟踪器的类似比较和更多信息,请参见 此处。

最大跟踪对象数

ObjectTracker 节点一次最多可以跟踪 60 个对象。目前,如果需要跟踪的对象超过 60 个,固件会崩溃。

用法

Python

Python
1pipeline = dai.Pipeline()
2objectTracker = pipeline.create(dai.node.ObjectTracker)
3
4objectTracker.setDetectionLabelsToTrack([15])  # 仅跟踪人
5# 可能的跟踪类型:ZERO_TERM_COLOR_HISTOGRAM, ZERO_TERM_IMAGELESS, SHORT_TERM_IMAGELESS, SHORT_TERM_KCF
6objectTracker.setTrackerType(dai.TrackerType.ZERO_TERM_COLOR_HISTOGRAM)
7# 当跟踪新对象时,取最小的 ID,可能的选项:SMALLEST_ID, UNIQUE_ID
8objectTracker.setTrackerIdAssignmentPolicy(dai.TrackerIdAssignmentPolicy.SMALLEST_ID)
9
10# 您必须将对象跟踪器与检测网络
11# 和图像帧源(单色/彩色相机或 xlinkIn 节点)结合使用

C++

C++
1dai::Pipeline pipeline;
2auto objectTracker = pipeline.create<dai::node.ObjectTracker>();
3
4objectTracker->setDetectionLabelsToTrack({15});  // 仅跟踪人
5// 可能的跟踪类型:ZERO_TERM_COLOR_HISTOGRAM, ZERO_TERM_IMAGELESS, SHORT_TERM_IMAGELESS, SHORT_TERM_KCF
6objectTracker->setTrackerType(dai::TrackerType.ZERO_TERM_COLOR_HISTOGRAM);
7// 当跟踪新对象时,取最小的 ID,可能的选项:SMALLEST_ID, UNIQUE_ID
8objectTracker->setTrackerIdAssignmentPolicy(dai::TrackerIdAssignmentPolicy::SMALLEST_ID);
9
10// 您必须将对象跟踪器与检测网络
11// 和图像帧源(单色/彩色相机或 xlinkIn 节点)结合使用

功能示例

参考

class

depthai.node.ObjectTracker(depthai.Node)

method
setDetectionLabelsToTrack(self, labels: collections.abc.Sequence [ typing.SupportsInt ])
Specify detection labels to track.  Parameter ``labels``:     Detection labels to track. Default every label is tracked from image     detection network output.
method
setMaxObjectsToTrack(self, maxObjectsToTrack: typing.SupportsInt)
Specify maximum number of object to track.  Parameter ``maxObjectsToTrack``:     Maximum number of object to track. Maximum 60 in case of SHORT_TERM_KCF,     otherwise 1000.
method
setOcclusionRatioThreshold(self, occlusionRatioThreshold: typing.SupportsFloat)
Specify occlusion ratio threshold.  Parameter ``occlusionRatioThreshold``:     Occlusion ratio threshold. Used to filter out overlapping tracklets. Default     0.4.
method
setTrackerIdAssignmentPolicy(self, type: depthai.TrackerIdAssignmentPolicy)
Specify tracker ID assignment policy.  Parameter ``type``:     Tracker ID assignment policy.
method
setTrackerThreshold(self, threshold: typing.SupportsFloat)
Specify tracker threshold.  Parameter ``threshold``:     Above this threshold the detected objects will be tracked. Default 0, all     image detections are tracked.
method
setTrackerType(self, type: depthai.TrackerType)
Specify tracker type algorithm.  Parameter ``type``:     Tracker type.
method
setTrackingPerClass(self, trackingPerClass: bool)
Whether tracker should take into consideration class label for tracking.
method
setTrackletBirthThreshold(self, threshold: typing.SupportsInt)
Specify tracklet birth threshold.  Parameter ``threshold``:     Tracklet birth threshold. Minimum consecutive tracked frames required to     consider a tracklet as a new instance. Default 3.
method
setTrackletMaxLifespan(self, lifespan: typing.SupportsInt)
Specify tracklet lifespan.  Parameter ``lifespan``:     Tracklet lifespan in number of frames. Number of frames after which a LOST     tracklet is removed. Default 120.
property
inputConfig
Input ObjectTrackerConfig message with ability to modify parameters at runtime. Default queue is non-blocking with size 4.
property
inputDetectionFrame
Input ImgFrame message on which object detection was performed. Default queue is non-blocking with size 4.
property
inputDetections
Input message with image detection from neural network. Default queue is non- blocking with size 4.
property
inputTrackerFrame
Input ImgFrame message on which tracking will be performed. RGBp, BGRp, NV12, YUV420p types are supported. Default queue is non-blocking with size 4.
property
out
Outputs Tracklets message that carries object tracking results.
property
passthroughDetectionFrame
Passthrough ImgFrame message on which object detection was performed. Suitable for when input queue is set to non-blocking behavior.
property
passthroughDetections
Passthrough image detections message from neural network output. Suitable for when input queue is set to non-blocking behavior.
property
passthroughTrackerFrame
Passthrough ImgFrame message on which tracking was performed. Suitable for when input queue is set to non-blocking behavior.

需要帮助?

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