MATLAB File Help: cv.DPMDetector Index
cv.DPMDetector

Deformable Part-based Models (DPM) detector

Discriminatively Trained Part Based Models for Object Detection

The object detector described below has been initially proposed by P.F. Felzenszwalb in [Felzenszwalb2010a]. 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.

The detector was dramatically speeded-up with cascade algorithm proposed by P.F. Felzenszwalb in [Felzenszwalb2010b]. The algorithm prunes partial hypotheses using thresholds on their scores. The basic idea of the algorithm is to use a hierarchy of models defined by an ordering of the original model's parts. For a model with (n+1) parts, including the root, a sequence of (n+1) models is obtained. The i-th model in this sequence is defined by the first i parts from the original model. Using this hierarchy, low scoring hypotheses can be pruned after looking at the best configuration of a subset of the parts. Hypotheses that score high under a weak model are evaluated further using a richer model.

Example

The basic usage is the following:

img = imread(fullfile(mexopencv.root(),'test','cat.jpg'));
detector = cv.DPMDetector(fullfile(mexopencv.root(),'test','cat.xml'));
detections = detector.detect(img);
for i=1:numel(detections)
    img = cv.rectangle(img, detections(i).rect, 'Color',[0 255 0]);
end
imshow(img)

The detector can also accept multiple models as cell array of strings:

detector = cv.DPMDetector({'cat.xml','car.xml'});

The XML file must be a format compatible to OpenCV's DPM detector, but you can convert models from the original implementation in [Felzenszwalb2010a] using cv.DPMDetector.mat2opencvxml method.

You can find examples of pre-trained models here: https://github.com/Itseez/opencv_extra/tree/3.1.0/testdata/cv/dpm/VOC2007_Cascade/

References

[Felzenszwalb2010a]:

P. Felzenszwalb, R. Girshick, D. McAllester, D. Ramanan "Object Detection with Discriminatively Trained Part Based Models". IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 32, No. 9, pages 1627-1645, Sep. 2010. http://www.cs.berkeley.edu/~rbg/papers/Object-Detection-with-Discriminatively-Trained-Part-Based-Models--Felzenszwalb-Girshick-McAllester-Ramanan.pdf

[Felzenszwalb2010b]:

Pedro F. Felzenszwalb, Ross B. Girshick, and David McAllester. "Cascade Object Detection with Deformable Part Models". IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2010, pages 2241-2248. http://www.cs.berkeley.edu/~rbg/papers/Cascade-Object-Detection-with-Deformable-Part-Models--Felzenszwalb-Girshick-McAllester.pdf

See also
Class Details
Superclasses handle
Sealed false
Construct on load false
Constructor Summary
DPMDetector Load and create a new detector 
Property Summary
id Object ID 
Method Summary
  addlistener Add listener for event. 
  delete Destructor 
  detect Detects objects 
  eq == (EQ) Test handle equality. 
  findobj Find objects matching specified conditions. 
  findprop Find property of MATLAB handle object. 
  ge >= (GE) Greater than or equal relation for handles. 
  getClassCount Return a count of loaded models (classes). 
  getClassNames Get names of the object classes 
  gt > (GT) Greater than relation for handles. 
  isEmpty Check if the detector is empty 
Sealed   isvalid Test handle validity. 
  le <= (LE) Less than or equal relation for handles. 
  lt < (LT) Less than relation for handles. 
Static   mat2opencvxml Convert DPM 2007 model (MAT) to cascade model (XML) 
  ne ~= (NE) Not equal relation for handles. 
  notify Notify listeners of event.