The object detector described below has been initially proposed by P.F. Felzenszwalb in [Felzenszwalb2010]. It is based on a Dalal-Triggs detector that uses a single filter on histogram of oriented gradients (HOG) features to represent an object category. This detector uses a sliding window approach, where a filter is applied at all positions and scales of an image. The first innovation is enriching the Dalal-Triggs model using a star-structured part-based model defined by a “root” filter (analogous to the Dalal-Triggs filter) plus a set of parts filters and associated deformation models. The score of one of star models at a particular position and scale within an image is the score of the root filter at the given location plus the sum over parts of the maximum, over placements of that part, of the part filter score on its location minus a deformation cost easuring the deviation of the part from its ideal location relative to the root. Both root and part filter scores are defined by the dot product between a filter (a set of weights) and a subwindow of a feature pyramid computed from the input image. Another improvement is a representation of the class of models by a mixture of star models. The score of a mixture model at a particular position and scale is the maximum over components, of the score of that component model at the given location.
In OpenCV there are C implementation of Latent SVM and C++ wrapper of it.
C version is the structure
CvObjectDetection and a set of functions
working with this structure (see
C++ version is the class
LatentSvmDetector and has slightly different
functionality in contrast with C version - it supports loading and detection
of several models.
There are two examples of Latent SVM usage:
Description of the filter, which corresponds to the part of the object.
ideal (penalty = 0) position of the partial filter from the root filter position (V_i in the paper)
vector describes penalty function (d_i in the paper) pf * x + pf * y + pf * x^2 + pf * y^2
Rectangular map (sizeX x sizeY), every cell stores feature vector (dimension = p)
number of features
matrix of feature vectors to set and get feature vectors (i,j) used formula H[(j * sizeX + i) * p + k], where k - component of feature vector in cell (i, j)
Structure contains internal representation of trained Latent SVM detector.
total number of filters (root plus part) in model
number of components in model
array containing number of part filters for each component
root and part filters for all model components
biases for all model components
confidence level threshold
Loads trained detector from a file.
cvLoadLatentSvmDetector(const char* filename)¶
Release memory allocated for CvLatentSvmDetector structure.
Find rectangular regions in the given image that are likely to contain objects and corresponding confidence levels.
cvLatentSvmDetectObjects(IplImage* image, CvLatentSvmDetector* detector, CvMemStorage* storage, float overlap_threshold=0.5f, int numThreads=-1 )¶
This is a C++ wrapping class of Latent SVM. It contains internal representation of several trained Latent SVM detectors (models) and a set of methods to load the detectors and detect objects using them.
Two types of constructors.
LatentSvmDetector(const vector<string>& filenames, const vector<string>& classNames=vector<string>())¶
Clear all trained models and their names stored in an class object.
Load the trained models from given
.xml files and return
true if at least one model was loaded.
load(const vector<string>& filenames, const vector<string>& classNames=vector<string>() )¶
Find rectangular regions in the given image that are likely to contain objects of loaded classes (models) and corresponding confidence levels.
detect(const Mat& image, vector<ObjectDetection>& objectDetections, float overlapThreshold=0.5f, int numThreads=-1 )¶
Return the class (model) names that were passed in constructor or method
load or extracted from models filenames in those methods.
Return a count of loaded models (classes).
|[Felzenszwalb2010]||Felzenszwalb, P. F. and Girshick, R. B. and McAllester, D. and Ramanan, D. Object Detection with Discriminatively Trained Part Based Models. PAMI, vol. 32, no. 9, pp. 1627-1645, September 2010|