|
#define | CC_FEATURE_PARAMS "featureParams" |
|
#define | CC_FEATURE_SIZE "featSize" |
|
#define | CC_FEATURES FEATURES |
|
#define | CC_ISINTEGRAL "isIntegral" |
|
#define | CC_MAX_CAT_COUNT "maxCatCount" |
|
#define | CC_NUM_FEATURES "numFeat" |
|
#define | CC_RECT "rect" |
|
#define | CC_RECTS "rects" |
|
#define | CC_TILTED "tilted" |
|
#define | CV_HAAR_FEATURE_MAX 3 |
|
#define | CV_SUM_OFFSETS(p0, p1, p2, p3, rect, step) |
|
#define | CV_TILTED_OFFSETS(p0, p1, p2, p3, rect, step) |
|
#define | FEATURES "features" |
|
#define | HFP_NAME "haarFeatureParams" |
|
#define | HOGF_NAME "HOGFeatureParams" |
|
#define | LBPF_NAME "lbpFeatureParams" |
|
#define | N_BINS 9 |
|
#define | N_CELLS 4 |
|
Long-term optical tracking API
Long-term optical tracking is an important issue for many computer vision applications in real world scenario. The development in this area is very fragmented and this API is an unique interface useful for plug several algorithms and compare them. This work is partially based on [169] and [114] .
These algorithms start from a bounding box of the target and with their internal representation they avoid the drift during the tracking. These long-term trackers are able to evaluate online the quality of the location of the target in the new frame, without ground truth.
There are three main components: the TrackerSampler, the TrackerFeatureSet and the TrackerModel. The first component is the object that computes the patches over the frame based on the last target location. The TrackerFeatureSet is the class that manages the Features, is possible plug many kind of these (HAAR, HOG, LBP, Feature2D, etc). The last component is the internal representation of the target, it is the appearence model. It stores all state candidates and compute the trajectory (the most likely target states). The class TrackerTargetState represents a possible state of the target. The TrackerSampler and the TrackerFeatureSet are the visual representation of the target, instead the TrackerModel is the statistical model.
A recent benchmark between these algorithms can be found in [217]
Creating Your Own Tracker
If you want to create a new tracker, here's what you have to do. First, decide on the name of the class for the tracker (to meet the existing style, we suggest something with prefix "tracker", e.g. trackerMIL, trackerBoosting) – we shall refer to this choice as to "classname" in subsequent.
- Declare your tracker in modules/tracking/include/opencv2/tracking/tracker.hpp. Your tracker should inherit from Tracker (please, see the example below). You should declare the specialized Param structure, where you probably will want to put the data, needed to initialize your tracker. You should get something similar to :
{
public:
struct CV_EXPORTS Params
{
Params();
float samplerInitInRadius;
int samplerInitMaxNegNum;
float samplerSearchWinSize;
float samplerTrackInRadius;
int samplerTrackMaxPosNum;
int samplerTrackMaxNegNum;
int featureSetNumFeatures;
void read(
const FileNode& fn );
void write( FileStorage& fs )
const;
};
of course, you can also add any additional methods of your choice. It should be pointed out, however, that it is not expected to have a constructor declared, as creation should be done via the corresponding create() method.
- Finally, you should implement the function with signature :
Ptr<classname> classname::create(const classname::Params ¶meters){
...
}
That function can (and probably will) return a pointer to some derived class of "classname", which will probably have a real constructor.
Every tracker has three component TrackerSampler, TrackerFeatureSet and TrackerModel. The first two are instantiated from Tracker base class, instead the last component is abstract, so you must implement your TrackerModel.
TrackerSampler is already instantiated, but you should define the sampling algorithm and add the classes (or single class) to TrackerSampler. You can choose one of the ready implementation as TrackerSamplerCSC or you can implement your sampling method, in this case the class must inherit TrackerSamplerAlgorithm. Fill the samplingImpl method that writes the result in "sample" output argument.
Example of creating specialized TrackerSamplerAlgorithm TrackerSamplerCSC : :
class CV_EXPORTS_W TrackerSamplerCSC :
public TrackerSamplerAlgorithm
{
public:
TrackerSamplerCSC( const TrackerSamplerCSC::Params ¶meters = TrackerSamplerCSC::Params() );
~TrackerSamplerCSC();
...
protected:
bool samplingImpl(
const Mat& image,
Rect boundingBox, std::vector<Mat>& sample );
...
};
Example of adding TrackerSamplerAlgorithm to TrackerSampler : :
Ptr<TrackerSamplerAlgorithm> CSCSampler = new TrackerSamplerCSC( CSCparameters );
if( !sampler->addTrackerSamplerAlgorithm( CSCSampler ) )
return false;
- See also
- TrackerSamplerCSC, TrackerSamplerAlgorithm
TrackerFeatureSet is already instantiated (as first) , but you should define what kinds of features you'll use in your tracker. You can use multiple feature types, so you can add a ready implementation as TrackerFeatureHAAR in your TrackerFeatureSet or develop your own implementation. In this case, in the computeImpl method put the code that extract the features and in the selection method optionally put the code for the refinement and selection of the features.
Example of creating specialized TrackerFeature TrackerFeatureHAAR : :
class CV_EXPORTS_W TrackerFeatureHAAR :
public TrackerFeature
{
public:
TrackerFeatureHAAR( const TrackerFeatureHAAR::Params ¶meters = TrackerFeatureHAAR::Params() );
~TrackerFeatureHAAR();
void selection( Mat& response, int npoints );
...
protected:
bool computeImpl( const std::vector<Mat>& images, Mat& response );
...
};
Example of adding TrackerFeature to TrackerFeatureSet : :
Ptr<TrackerFeature> trackerFeature = new TrackerFeatureHAAR( HAARparameters );
featureSet->addTrackerFeature( trackerFeature );
- See also
- TrackerFeatureHAAR, TrackerFeatureSet
TrackerModel is abstract, so in your implementation you must develop your TrackerModel that inherit from TrackerModel. Fill the method for the estimation of the state "modelEstimationImpl", that estimates the most likely target location, see [169] table I (ME) for further information. Fill "modelUpdateImpl" in order to update the model, see [169] table I (MU). In this class you can use the :cConfidenceMap and :cTrajectory to storing the model. The first represents the model on the all possible candidate states and the second represents the list of all estimated states.
Example of creating specialized TrackerModel TrackerMILModel : :
class TrackerMILModel : public TrackerModel
{
public:
TrackerMILModel(
const Rect& boundingBox );
~TrackerMILModel();
...
protected:
void modelEstimationImpl( const std::vector<Mat>& responses );
void modelUpdateImpl();
...
};
And add it in your Tracker : :
{
...
model =
new TrackerMILModel( boundingBox );
...
}
In the last step you should define the TrackerStateEstimator based on your implementation or you can use one of ready class as TrackerStateEstimatorMILBoosting. It represent the statistical part of the model that estimates the most likely target state.
Example of creating specialized TrackerStateEstimator TrackerStateEstimatorMILBoosting : :
class CV_EXPORTS_W TrackerStateEstimatorMILBoosting :
public TrackerStateEstimator
{
class TrackerMILTargetState : public TrackerTargetState
{
...
};
public:
TrackerStateEstimatorMILBoosting( int nFeatures = 250 );
~TrackerStateEstimatorMILBoosting();
...
protected:
Ptr<TrackerTargetState> estimateImpl( const std::vector<ConfidenceMap>& confidenceMaps );
void updateImpl( std::vector<ConfidenceMap>& confidenceMaps );
...
};
And add it in your TrackerModel : :
Ptr<TrackerStateEstimatorMILBoosting> stateEstimator = new TrackerStateEstimatorMILBoosting( params.featureSetNumFeatures );
model->setTrackerStateEstimator( stateEstimator );
- See also
- TrackerModel, TrackerStateEstimatorMILBoosting, TrackerTargetState
During this step, you should define your TrackerTargetState based on your implementation. TrackerTargetState base class has only the bounding box (upper-left position, width and height), you can enrich it adding scale factor, target rotation, etc.
Example of creating specialized TrackerTargetState TrackerMILTargetState : :
class TrackerMILTargetState : public TrackerTargetState
{
public:
TrackerMILTargetState(
const Point2f& position,
int targetWidth,
int targetHeight,
bool foreground,
const Mat& features );
~TrackerMILTargetState();
...
private:
bool isTarget;
Mat targetFeatures;
...
};
§ CC_FEATURE_PARAMS
#define CC_FEATURE_PARAMS "featureParams" |
§ CC_FEATURE_SIZE
#define CC_FEATURE_SIZE "featSize" |
§ CC_FEATURES
§ CC_ISINTEGRAL
#define CC_ISINTEGRAL "isIntegral" |
§ CC_MAX_CAT_COUNT
#define CC_MAX_CAT_COUNT "maxCatCount" |
§ CC_NUM_FEATURES
#define CC_NUM_FEATURES "numFeat" |
§ CC_RECT
§ CC_RECTS
§ CC_TILTED
#define CC_TILTED "tilted" |
§ CV_HAAR_FEATURE_MAX
#define CV_HAAR_FEATURE_MAX 3 |
§ CV_SUM_OFFSETS
#define CV_SUM_OFFSETS |
( |
|
p0, |
|
|
|
p1, |
|
|
|
p2, |
|
|
|
p3, |
|
|
|
rect, |
|
|
|
step |
|
) |
| |
Value: \
(p0) = (rect).x + (step) * (rect).y; \
\
(p1) = (rect).x + (rect).width + (step) * (rect).y; \
\
(p2) = (rect).x + (step) * ((rect).y + (rect).height); \
\
(p3) = (rect).x + (rect).width + (step) * ((rect).y + (rect).height);
§ CV_TILTED_OFFSETS
#define CV_TILTED_OFFSETS |
( |
|
p0, |
|
|
|
p1, |
|
|
|
p2, |
|
|
|
p3, |
|
|
|
rect, |
|
|
|
step |
|
) |
| |
Value: \
(p0) = (rect).x + (step) * (rect).y; \
\
(p1) = (rect).x - (rect).height + (step) * ((rect).y + (rect).height);\
\
(p2) = (rect).x + (rect).width + (step) * ((rect).y + (rect).width); \
\
(p3) = (rect).x + (rect).width - (rect).height \
+ (step) * ((rect).y + (rect).width + (rect).height);
§ FEATURES
#define FEATURES "features" |
§ HFP_NAME
#define HFP_NAME "haarFeatureParams" |
§ HOGF_NAME
#define HOGF_NAME "HOGFeatureParams" |
§ LBPF_NAME
#define LBPF_NAME "lbpFeatureParams" |
§ N_BINS
§ N_CELLS
§ ConfidenceMap
Represents the model of the target at frame \(k\) (all states and scores)
See [169] The set of the pair \(\langle \hat{x}^{i}_{k}, C^{i}_{k} \rangle\)
- See also
- TrackerTargetState
§ Trajectory
Represents the estimate states for all frames.
[169] \(x_{k}\) is the trajectory of the target up to time \(k\)
- See also
- TrackerTargetState
§ _writeFeatures()
template<class Feature >
void cv::_writeFeatures |
( |
const std::vector< Feature > |
features, |
|
|
FileStorage & |
fs, |
|
|
const Mat & |
featureMap |
|
) |
| |
§ calc() [1/2]
float cv::CvHOGEvaluator::Feature::calc |
( |
const std::vector< Mat > & |
_hists, |
|
|
const Mat & |
_normSum, |
|
|
size_t |
y, |
|
|
int |
featComponent |
|
) |
| const |
|
inline |
§ calc() [2/2]
uchar cv::CvLBPEvaluator::Feature::calc |
( |
const Mat & |
_sum, |
|
|
size_t |
y |
|
) |
| const |
|
inline |
§ calcNormFactor()
float cv::calcNormFactor |
( |
const Mat & |
sum, |
|
|
const Mat & |
sqSum |
|
) |
| |
§ operator()()
float cv::CvHOGEvaluator::operator() |
( |
int |
varIdx, |
|
|
int |
sampleIdx |
|
) |
| |
|
inlinevirtual |