11

I have a question about CascadeObjectDetector in MATLAB. In source code of CascadeObjectDetector in MATLAB I see:

pCascadeClassifier; % OpenCV pCascadeClassifier 

Then I see:

%------------------------------------------------------------------
% Constructor
%------------------------------------------------------------------
function obj = CascadeObjectDetector(varargin)              
    obj.pCascadeClassifier = vision.internal.CascadeClassifier;
    ...
end

And in stepImpl:

bbox = double(obj.pCascadeClassifier.detectMultiScale(I, ...
            double(obj.ScaleFactor), ...
            uint32(obj.MergeThreshold), ...            
            uint32(obj.MinSize), ...
            uint32(obj.MaxSize)));

Do you know, what is vision.internal.CascadeClassifier? Is it simply OpenCV CascadeClassifier? And where is source code of detectMultiScale function?

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
EgorD
  • 886
  • 6
  • 12
  • The latest OpenCV's detectMultiscale is [here](http://code.opencv.org/projects/opencv/repository/revisions/master/entry/modules/objdetect/src/cascadedetect.cpp#L1089) – Andrey Kamaev Sep 25 '12 at 22:52

1 Answers1

0

The thing is that matlab provides the following object detectors

  1. template matching
  2. blob analysis
  3. viola-jones algorithm More info here : http://www.mathworks.ch/products/computer-vision/description4.html

Now to talk about opencv. The opencv function cv.HaarDetectObjects() which is used for faces detection (and in general for object detection) uses the viola jones algorithm which inturn uses harr like features.

My personal opinion is that the implementations may be slightly different but they essentially have the same algorithm.

If you are still not convinced and would like to use opencv function from matlab, u can use MEX. So this way u can use the cv.HaarDetectObjects() from matlab. More details are available at : http://www.mathworks.ch/discovery/matlab-opencv.html

mkuse
  • 2,250
  • 4
  • 32
  • 61
  • The main problem is that MATLAB version works much better than OpenCV. For example, MATLAB finds faces in sunglasses by FaceCascadeDetector very often, but OpenCV finds faces in sunglasses very rare. You think this is because of MATLAB uses three algorithms and OpenCV uses only one algorithm, right? – EgorD Oct 08 '12 at 16:21
  • no, thtz not the reason to my belief. I believe, its about what kind of templates (training data) is used. – mkuse Oct 09 '12 at 17:21
  • MATLAB and OpenCV use the same cascade. So the problem is not in training data, it is in the code. – EgorD Mar 12 '13 at 18:11