latest version v1.9 - last update 10 Apr 2010 |
This is the implementation of the MEANSHIFT Tracking algorithm as described in: Comaniciu, Ramesh and Meer, "Real-Time Tracking of Non-Rigid Objects using the Mean Shift", IEEE Workshop on Applic.Comp.Vis.,2000. More...
#include <ltiMeanshiftTracker.h>
Classes | |
class | parameters |
the parameters for the class meanshiftTracker More... | |
Public Member Functions | |
meanshiftTracker () | |
meanshiftTracker (const meanshiftTracker &other) | |
virtual | ~meanshiftTracker () |
virtual const char * | getTypeName () const |
bool | apply (const image &src, trectangle< int > &window) |
bool | isInitialized () const |
void | initialize (const image &src, trectangle< int > &window) |
void | initialize (const image &src, trectangle< int > &window, const channel8 &mask) |
void | initialize (const image &src, trectangle< int > &window, const channel &mask) |
void | reset () |
bool | isValid () const |
float | getDistance () const |
tpoint< float > | getCenter () const |
const thistogram< float > & | getTargetHist () const |
const thistogram< float > & | getCandidateHist () const |
meanshiftTracker & | copy (const meanshiftTracker &other) |
meanshiftTracker & | operator= (const meanshiftTracker &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
This is the implementation of the MEANSHIFT Tracking algorithm as described in: Comaniciu, Ramesh and Meer, "Real-Time Tracking of Non-Rigid Objects using the Mean Shift", IEEE Workshop on Applic.Comp.Vis.,2000.
It tracks a rectangular search window (the target) in an image by its color distribution. Therefore it uses an iterative gradient ascent algorithm, known as mean shift, that finds a similarity peak between target and candidate positions. The similarity is measured with a distance metric, which can be obtained after each apply().
Use this by calling an apply on subsequent images and thereby passing the last returned search rectangle. Initialization is done with first use or after a call of the reset() method.
lti::meanshiftTracker::meanshiftTracker | ( | ) |
default constructor
lti::meanshiftTracker::meanshiftTracker | ( | const meanshiftTracker & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::meanshiftTracker::~meanshiftTracker | ( | ) | [virtual] |
destructor
bool lti::meanshiftTracker::apply | ( | const image & | src, | |
trectangle< int > & | window | |||
) |
virtual functor* lti::meanshiftTracker::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
meanshiftTracker& lti::meanshiftTracker::copy | ( | const meanshiftTracker & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
const thistogram<float>& lti::meanshiftTracker::getCandidateHist | ( | ) | const |
returns a const reference to the histogram of the tracked candidate.
The histogram changes after each call of an apply method.
tpoint<float> lti::meanshiftTracker::getCenter | ( | ) | const |
returns the center of the tracked candidate distribution.
In general, this is the returned search windows center, except that the winwod is at the fringe of the image.
float lti::meanshiftTracker::getDistance | ( | ) | const |
returns the distance between the color distribution of the initial target and the last returned window.
const parameters& lti::meanshiftTracker::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::modifier.
const thistogram<float>& lti::meanshiftTracker::getTargetHist | ( | ) | const |
returns a const reference to the histogram of the target.
The histogram only changes on initialization.
virtual const char* lti::meanshiftTracker::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("meanshiftTracker")
Reimplemented from lti::modifier.
void lti::meanshiftTracker::initialize | ( | const image & | src, | |
trectangle< int > & | window, | |||
const channel & | mask | |||
) |
Explicitly initialize tracker with given region in image.
Additionally weight all pixels with the value in mask. You must call this explicitly, if you want to initialize with a weighting mask.
void lti::meanshiftTracker::initialize | ( | const image & | src, | |
trectangle< int > & | window, | |||
const channel8 & | mask | |||
) |
Explicitly initialize tracker with given region in image.
Additionally weight all pixels with the value in mask. You must call this explicitly, if you want to initialize with a weighting mask.
void lti::meanshiftTracker::initialize | ( | const image & | src, | |
trectangle< int > & | window | |||
) |
Explicitly initialize tracker with given region in image.
This is called automatically when an apply is used while tracker is not initialised. I.e. calling initialize() is the same as subsequently calling reset() and apply().
bool lti::meanshiftTracker::isInitialized | ( | ) | const |
Tells, if the tracker has already been initialized with a target color distribution.
bool lti::meanshiftTracker::isValid | ( | ) | const |
Tells if returned window is valid.
This depends on the threshold parameter. If the color distribution distance between target and candidate window is above threshold, then this method returns false.
meanshiftTracker& lti::meanshiftTracker::operator= | ( | const meanshiftTracker & | other | ) |
void lti::meanshiftTracker::reset | ( | ) |
Resets the tracker.
Next call of apply initializes it again.