Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Shaban,

if you want to detect persons in ROI`s (given by each contour) you have to check that the ROI is larger than the used HoG detector size. cv::HOGDescriptor.detectMultiScale will crash if the ROI is smaller than the detector size. In your case you load a detector with height 96 and width 48. But you check if the number of the points of a contour is in a certain range (min = 50, max 1000).

if (itc->size() > cmin && itc->size() < cmax)

To get the bounding rectangle of the ROI use the points of each contour.

cv::Rect object_bounding_box = cv::boundingRect(*itc);

Now, check if the height and width of the object_bounding_box is larger than the HoG detector.

if(object_bounding_box.height > human.winSize.height && object_bounding_box.width > human.winSize.width)

After the check you can take the ROI and run detectMultiScale on it.

cv::Mat object_roi = gray(object_bounding_box);
human.detectMultiScale(object_roi, rects);