Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Tracker

Guide for the Impatient

If you just want to use the tracker you still need to know two important facts:

Here is some pseudo code:

CornerDetectorKLT<StorageType, CalculationType> cd;
Tracker<StorageType, CalculationType> tr(TT_Simple);
//set parameters
Vector<int> hws; hws.newsize(5);
hws[4] =hws[3] = hws[2] =hws[1] =hws[0] = 10;
tr.SetHalfWinSize(hws);
tr.SetRejectionType(-1);
tr.SetAffineBrightnessInvariance(true);
// two sets of images are needed for the tracker
PyramidImage<CalculationType> pim[2], gx[2], gy[2];
int act=0; // index into the actual image set
// temporary vector for the points and covariances
vector<HomgPoint2D> mp;
vector<QUAL> qual;
//Pyramid filter image
tr.PreparePyramide(im, pyim[act], gx[act], gy[act]);
// now initially tell the tracker where to track
// by detecting corners using CornerDetectorKLT
cd.Detect(*(gx[act])[0], *(gy[act])[0], mp, qual);
cout << "initially found "<<mp.size()<<" points\n";
//and set points to tracker
tr.ReplaceAllPoints(mp, qual);
for every image do:
1. tr.PreparePyramide(im, pyim[act], gx[act], gy[act]);
2. tr.Track(pyim[act], gx[act], gy[act]);
3. If first image then tr.ReplaceAllPoints(mp, qual);
If points need to be filled up then tr.FillUpPoints(mp, qual);
4. tr.GetPoints(mp); // retrieve the point positions in actual image
5. act=!act; // toggle the set of used images

Point Manipulation Functions

A number of functions for manipulation of the internal data structures exist. The most commenly used beeing

Tracker Output

A number of results can be accesed which can be used to asses the correspondences:

Tracker Parameter

Class Hirarchy

Two niveaus of tracking classes exist:

TrackerBase TrackerBase

The TrackerBase computes image point correspondences between two images. It does not have an internal state and does not use pyramid images. Derived from TrackerBaseInterface are TrackerBaseSimple (the standard tracker), TrackerBaseWeighted (decreasing weight in outer patch regions) and TrackerBaseAffine (affine or similar warp of the whole patch). It can handle different outlier rejection algorithms based on parametrization:

Tracker Class

This is a convenient class for the tracking functionality. It can be used very easily, even though two footangles exist:

  1. The tracker has an internal state, i.e. it holds pointers to the last images. So do not remove or overwrite images or gradient images before tracking is finished! It also holds an internal list of tracked points. It is hence not necessary to call a point manipulation function in every cycle.
  2. The function Tracker::Track() is always called before any point manipulation functions.

See the examples in the subdirectory Matcher2D/Examples for how to use the tracker.

Generic Image Alignment

The tracker implements gradient-based image alignment according to an additive model, i.e. a parameter prediction is "tested" in an analysis-by-synthesis fashion and the remaining grey value difference is exploited to compute an additive update onto the parameter vector. For more complicated warps than displacement (e.g. affine) it is much more efficient to use inverse compositional alignment to track a patch trough a sequence. The class BIAS::ImageAlignment is a generic implementation to compute arbitrary (groupwise) warps based on image differences, e.g. a homography or affine transform.

Instead of using a pyramid, it is possible to provide an uncertainty of the predicted (homography, displacement, ...) parameters, such that automatic smoothing is done. This is particularly interesting e.g. for rotational warps. The generic alignment is only a reference implementation not optimized for speed, for fast affine tracking through an image sequence a specialized implementation should be considered.