Ask Your Question

Is it possible to run the CascadeClassifer without preprocessing?

asked 2016-11-30 05:36:30 -0500

DerrickB gravatar image

updated 2016-11-30 05:37:32 -0500

Hello OpenCV Community,

is it possible to run the CascadeClassifier without the Preprocessing (Sliding Window and Image Pyramid). I mean i want to give really small image fragments as input (e.g. 24x24) and the Classifier should just say positive or negative.

If i put the ScaleFactor and minSize of the multidetect method to "1" and minSize to "24x24" the method crashes.

This is for research and performance test.

Thank you very much,

Kind regards,


edit retag flag offensive close merge delete



here you will find the answer

sturkmen gravatar imagesturkmen ( 2016-11-30 06:43:02 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-05 03:13:34 -0500

pi-null-mezon gravatar image

Hello. First, scale factor should be greaer than the 1.0, it is pretty evident because CascadeClassifier::detectMultiScale function uses this value to calculate the ammount of the scale steps (so for 1 it is infinite, so your code crashes because of memory consumption). Second, of cource you can detect without any scale and shift, use CascadeClassifier::setImage and CascadeClassifier::runAt

edit flag offensive delete link more


i cant find the methods "setImage" or "runAt". I think they are private or something???

DerrickB gravatar imageDerrickB ( 2016-12-12 04:25:25 -0500 )edit

Sorry, it seems that this docs are outdated. In actual API you should use detectMultiScale with options. For the instance if you have WxH _image with region of interest 24x24 than do:

cv::Mat _roimat(_image, cv::Rect(_targetX,_targetY,24,24)); // manually select the roi region 
std::vector<cv::Rect> _vrects; // this vector will store the detector's output
_cascadeclassifier.detectMultiScale(_roimat, _vrects, 1.1, 3, 0, cv::Size(24,24), cv::Size(24,24));
pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-12 12:33:14 -0500 )edit

Yes with this solution it works, thanks!

DerrickB gravatar imageDerrickB ( 2016-12-16 06:28:38 -0500 )edit

Question Tools

1 follower


Asked: 2016-11-30 05:36:30 -0500

Seen: 121 times

Last updated: Dec 05 '16