Table of Contents

Class LegacyTracker

Namespace
OpenCvSharp.Tracking.Legacy
Assembly
OpenCvSharp.dll

Base abstract class for the long-term tracker, mirroring cv::legacy::Tracker.

public abstract class LegacyTracker : Algorithm, IDisposable
Inheritance
LegacyTracker
Implements
Derived
Inherited Members

Remarks

This is a distinct type from Tracker (the modern, video-module tracker base): cv::legacy::Tracker::init/update return bool (not void) and operate on Rect2d (not Rect), so the two hierarchies cannot share a common managed base class.

Constructors

LegacyTracker(nint, nint, Action<nint>)

Constructor for the factory pattern (cv::Ptr<T>* + raw T*).

protected LegacyTracker(nint smartPtr, nint rawPtr, Action<nint> releaseSmartPtr)

Parameters

smartPtr nint
rawPtr nint
releaseSmartPtr Action<nint>

Methods

Init(Mat, Rect2d)

Initialize the tracker with a known bounding box that surrounded the target.

public bool Init(Mat image, Rect2d boundingBox)

Parameters

image Mat

The initial frame

boundingBox Rect2d

The initial bounding box

Returns

bool

True if initialization went successfully, false otherwise

Update(Mat, ref Rect2d)

Update the tracker, find the new most likely bounding box for the target.

public bool Update(Mat image, ref Rect2d boundingBox)

Parameters

image Mat

The current frame

boundingBox Rect2d

The bounding box that represents the new target location, if true was returned, not modified otherwise

Returns

bool

True means that target was located and false means that tracker cannot locate target in the current frame. Note that the latter does not imply that tracker has failed - the target may indeed be missing from the frame (say, out of sight).