# hog.detectMultiScale exits program without any warning, if the given image is smaller than a threshold.

I try to run a pedestrian detector with hog.detectMultiScale(). However, I realized that if the given image is smaller than a threshold, it exits the program without any warning. I also did not see any comment in the docs about any limitation of image size. I am using OpenCV3 and here is the section of my code with a naive solution.;

                Rect bb = boundingBoxes[i];

// ignore too small bbs
if(bb.area() < BB_THRESHOLD || bb.height < 60 || bb.width < 60)
continue;

cout << bb.height << endl;
cout << bb.width << endl;

// get bb image and run detector
Mat bb_image = fg(bb);
hog.detectMultiScale(bb_image, found, 0, Size(5,5), Size(30,30), 1.0, 0, true);


However if I make smaller Size(30,30) to Size(10,10), I also need to increase the check sizes. I could not figure out what is the exact size threshold but this is the case. Any idea for the solution or does it seem like a bug in opencv?

edit retag close merge delete

1

If your image size is smaller than the HOG window size it can not perform detection. If that's what is happening here (difficult to say as you don't say which is that threshold you're talking about) it's not a bug

( 2015-06-10 12:59:30 -0500 )edit

Sort by » oldest newest most voted

HOG has, according to the Dallal and Triggs paper that was followed for the HOG interface, a window size of 64x128pixels. As far as I know this is the model size of the OpenCV implementation, which means that smaller objects cannot be detected. Reason for this is that the image pyramid is generated by downsampling the original image and thus leading to multi scale detections (from model size to larger persons). If you want to be able to detect smaller persons you need to manually upscale your image. However keep in mind that upscaling to much will introduce scaling artefacts that will definitely influence the models detection performance.

I have applications where upscaling it to double the original size worked, but than the smallest objects did not contain enough usefull pixel information anymore to be detected by the trained model.

Keep in mind that detections found on the upscaled version need to be manually resized the the original window size by the user, since the image pyramid doesn't contain upscaling in OpenCV.

more

1

I don't remember which is which right now, but either the DefaultPeopleDetector or the DaimlerPeopleDetector has a windows size of 48x96 (and the other 64x128 as you said)

( 2015-06-11 10:08:42 -0500 )edit

The DefaultPeopleDetector is the one with size 64x128, indeed DaimlerPeopleDetector has other aspect ratio for the window size, which is 48x96 pixels :)

( 2015-06-12 01:47:15 -0500 )edit

Official site

GitHub

Wiki

Documentation