Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

open CV detect multiscal issue

Dears, im working with the object detection functions, exactly with the detect multiscal , and my problem that in some times "detectMultiScale" function detect objects(in my case faces) and when i try to get the ROI of that face, open CV throw an exception as follow:

terminate called after throwing an instance of 'cv::Exception' what(): /home/mohammad/yabrodi/opencv/opencv-3.0.0-alpha/modules/core/src/matrix.cpp:492: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat

After investigation i found that "detectMultiScale" return an object of size greater than the original image used in the detection process. an exact case occurs as follow :

face_cascade.detectMultiScale(frame , faces_in_frame, 1.3, 2, 0| CASCADE_SCALE_IMAGE, Size(25, 25) ); frame.size().width = 720
frame.size().height = 565

faces_in_frame[0].x = 30
faces_in_frame[0].y = 137
faces_in_frame[0].width = 430
faces_in_frame[0].height = 430

and when i tried to get the ROI i got the exception above which is true since the height of the object is (137+ 430 = 567) which is grater than the frame height (565).

SO, what is the issue that let "detectMultiScale" return object with invalid size ???

my OpenCV version 3.1

thanks