DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.

本页目录

  • 如何放置
  • 输入和输出
  • 零项跟踪
  • 短期跟踪
  • 支持的对象跟踪器类型
  • 最大跟踪对象数量
  • 使用示例
  • 功能示例
  • 参考

ObjectTracker

ObjectTracker 使用卡尔曼滤波和匈牙利算法跟踪来自 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# 必须将对象跟踪器与检测网络以及图像帧源(单目/彩色相机或 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// 必须将对象跟踪器与检测网络以及图像帧源(单目/彩色相机或 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.

需要帮助?

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