Class that manages the sampler in order to select regions for the update the model of the tracker
[AAM] Sampling e Labeling. See table I and section III B
TrackerSampler class:
class CV_EXPORTS_W TrackerSampler
{
public:
TrackerSampler();
~TrackerSampler();
void sampling( const Mat& image, Rect boundingBox );
const std::vector<std::pair<String, Ptr<TrackerSamplerAlgorithm> > >& getSamplers() const;
const std::vector<Mat>& getSamples() const;
bool addTrackerSamplerAlgorithm( String trackerSamplerAlgorithmType );
bool addTrackerSamplerAlgorithm( Ptr<TrackerSamplerAlgorithm>& sampler );
};
TrackerSampler is an aggregation of TrackerSamplerAlgorithm
See also
Computes the regions starting from a position in an image
Parameters: |
|
---|
Return the collection of the TrackerSamplerAlgorithm
Return the samples from all TrackerSamplerAlgorithm, [AAM] Fig. 1 variable Sk
Add TrackerSamplerAlgorithm in the collection. Return true if sampler is added, false otherwise
Parameters: |
|
---|
Parameters: |
|
---|
The modes available now:
Example TrackerSamplerAlgorithm::addTrackerSamplerAlgorithm :
//sample usage:
TrackerSamplerCSC::Params CSCparameters;
Ptr<TrackerSamplerAlgorithm> CSCSampler = new TrackerSamplerCSC( CSCparameters );
if( !sampler->addTrackerSamplerAlgorithm( CSCSampler ) )
return false;
//or add CSC sampler with default parameters
//sampler->addTrackerSamplerAlgorithm( "CSC" );
Note
If you use the second method, you must initialize the TrackerSamplerAlgorithm
Abstract base class for TrackerSamplerAlgorithm that represents the algorithm for the specific sampler.
TrackerSamplerAlgorithm class:
class CV_EXPORTS_W TrackerSamplerAlgorithm
{
public:
virtual ~TrackerSamplerAlgorithm();
static Ptr<TrackerSamplerAlgorithm> create( const String& trackerSamplerType );
bool sampling( const Mat& image, Rect boundingBox, std::vector<Mat>& sample );
String getClassName() const;
};
Create TrackerSamplerAlgorithm by tracker sampler type.
Parameters: |
|
---|
The modes available now:
Computes the regions starting from a position in an image. Return true if samples are computed, false otherwise
In [AAM] table I there are described the most known sampling strategies. At moment TrackerSamplerCSC and TrackerSamplerCS are implemented. Beside these, there is TrackerSamplerPF, sampler based on particle filtering.
TrackerSampler based on CSC (current state centered), used by MIL algorithm TrackerMIL
TrackerSamplerCSC class:
class CV_EXPORTS_W TrackerSamplerCSC
{
public:
TrackerSamplerCSC( const TrackerSamplerCSC::Params ¶meters = TrackerSamplerCSC::Params() );
void setMode( int samplingMode );
~TrackerSamplerCSC();
};
List of TrackerSamplerCSC parameters:
struct CV_EXPORTS Params
{
Params();
float initInRad; // radius for gathering positive instances during init
float trackInPosRad; // radius for gathering positive instances during tracking
float searchWinSize; // size of search window
int initMaxNegNum; // # negative samples to use during init
int trackMaxPosNum; // # positive samples to use during training
int trackMaxNegNum; // # negative samples to use during training
};
Constructor
Parameters: |
|
---|
Set the sampling mode of TrackerSamplerCSC
Parameters: |
|
---|
The modes are:
TrackerSampler based on CS (current state), used by algorithm TrackerBoosting
TrackerSamplerCS class:
class CV_EXPORTS_W TrackerSamplerCS
{
public:
TrackerSamplerCS( const TrackerSamplerCS::Params ¶meters = TrackerSamplerCS::Params() );
void setMode( int samplingMode );
~TrackerSamplerCS();
};
List of TrackerSamplerCS parameters:
struct CV_EXPORTS Params
{
Params();
float overlap; //overlapping for the search windows
float searchFactor; //search region parameter
};
Constructor
Parameters: |
|
---|
Set the sampling mode of TrackerSamplerCS
Parameters: |
|
---|
The modes are:
This sampler is based on particle filtering. In principle, it can be thought of as performing some sort of optimization (and indeed, this tracker uses opencv’s optim module), where tracker seeks to find the rectangle in given frame, which is the most “similar” to the initial rectangle (the one, given through the constructor).
The optimization performed is stochastic and somehow resembles genetic algorithms, where on each new image received (submitted via TrackerSamplerPF::sampling()) we start with the region bounded by boundingBox, then generate several “perturbed” boxes, take the ones most similar to the original. This selection round is repeated several times. At the end, we hope that only the most promising box remaining, and these are combined to produce the subrectangle of image, which is put as a sole element in array sample.
It should be noted, that the definition of “similarity” between two rectangles is based on comparing their histograms. As experiments show, tracker is not very succesfull if target is assumed to strongly change its dimensions.
TrackerSamplerPF class:
class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm{
public:
TrackerSamplerPF(const Mat& chosenRect,const TrackerSamplerPF::Params ¶meters = TrackerSamplerPF::Params());
void sampling( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ); //inherited from TrackerSamplerAlgorithmTrackerSamplerAlgorithm
};
This structure contains all the parameters that can be varied during the course of sampling algorithm. Below is the structure exposed, together with its members briefly explained with reference to the above discussion on algorithm’s working.
struct CV_EXPORTS Params
{
Params();
int iterationNum; //number of selection rounds
int particlesNum; //number of "perturbed" boxes on each round
double alpha; //with each new round we exponentially decrease the amount of "perturbing" we allow (like in simulated annealing)
//and this very alpha controls how fast annealing happens, ie. how fast perturbing decreases
Mat_<double> std; //initial values for perturbing (1-by-4 array, as each rectangle is given by 4 values -- coordinates of opposite vertices,
//hence we have 4 values to perturb)
};