The Tracker Interface - asolis/vivaTracker GitHub Wiki

Overview

To create a new tracker you need to inherit the Tracker interface defined in tracker.h and implement its 4 virtual methods.

void virtual getTrackedArea(vector<Point2f> &pts) = 0;
void virtual initialize(const cv::Mat &image,
                          const cv::Rect &rect) = 0;
void virtual processFrame(const cv::Mat &image) = 0;
string virtual getDescription() { return "default";};

A trackers life cycle its defined by three actions: creation, initialization, and updating. The tracking creation is archived by the trackers constructors; algorithms with multiple configurations and/or options parameters should be declared them in their constructor. Initialization is done by selecting a rectangular area of the initial video frame (i.e., initialize method). updating the trackers position by analyzing consecutive frames from the sequence (i.e., processFrame).

The getDescription method is used for integration with the framework with details of the implementation.

The complete Tracker interface is as follow (with comments)

using namespace std;
using namespace cv;

/*
 * Tracker interface
 */
class Tracker
{
public:
    
  /*
   * This outputs the tracked area in clockwise order. e.g. : 
   * topLeft - > topRight -> bottomRight -> bottomLeft.
   * @param vector<Point2f> &pts. The output tracked area 
   */
  void virtual getTrackedArea(vector<Point2f> &pts) = 0;
    
  /*
   * Initialize the tracker using an image and the selected area
   * as a axis-align rectangle. 
   * @param Mat &image,       The first reference frame where the area is specified.
   * @param Rect &rect        Rectangular region. 
   */
  void virtual initialize(const cv::Mat &image,
                          const cv::Rect &rect) = 0;
  /*
   * This will be called every frame after the tracker is initialized.
   * The image is the current frame being processed.
   * @param Mat &image. processing frame.
   */
  void virtual processFrame(const cv::Mat &image) = 0;
    
  /*
   * Each tracker has a string description of the implemented 
   * algorithm. This string will be displayed when asking for the algorithms
   * options. 
   * e.g.  "Author, Algorithm Name, Full Algorithm Name, [PUblication], etc".
   */
   string virtual getDescription() { return "default";};
    
  /*
   * Just in case dynamic allocated memory needs to be destroyed
   */
  virtual ~Tracker(){}
};
⚠️ **GitHub.com Fallback** ⚠️