OpenCV 2.4 CascadeClassified detectMultiScale arguments

George Profenza picture George Profenza · Jul 28, 2012 · Viewed 7.4k times · Source

I was looking at the objectdetect sample and tried it with a couple of body detection cascades(*haarcascade_fullbody/haarcascade_upperbody/haarcascade_lowerbody,haarcascade_mcs_upperbody*) on some footage I took with a camera of a pedestrian bridge. So far so good, but it's a demanding functionality.

I though thinks might run smoother if I pass the min/max Sizes since my camera is always in the same place and I figure out the min/max bounding boxes. Unfortunately I ran into syntax errors when trying to do so:

//my call
body.detectMultiScale( gray, bodies, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, cv::Size(30, 30),cv::Size(0,0),cv::Size(5,13),cv::Size(45,80));
//errors:
main.cpp:43: error: no matching function for call to 'cv::CascadeClassifier::detectMultiScale(cv::Mat&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size, cv::Size, cv::Size, cv::Size)'
/opt/local/include/opencv2/objdetect/objdetect.hpp:383: note: candidates are: virtual void cv::CascadeClassifier::detectMultiScale(const cv::Mat&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size, cv::Size)
/opt/local/include/opencv2/objdetect/objdetect.hpp:393: note:                 virtual void cv::CascadeClassifier::detectMultiScale(const cv::Mat&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, cv::Size, cv::Size, bool)

I simply added two cv::Size objects as the min max, but to be honest I'm not sure:

  1. Why the previous arguments are Size() objects as well when the docs list them as ints ?
  2. Am I looking at the wrong docs or at the docs in a wrong way ?

C++: void CascadeClassifier::detectMultiScale(const Mat& image, vector& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())

from docs.

Answer

George Profenza picture George Profenza · Jul 28, 2012

It seems I was passing the wrong arguments. This worked:

body.detectMultiScale(gray,bodies,1.1,3,3,cv::Size(5,13),cv::Size(45,80));