Ask Your Question
0

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

asked 2015-06-10 12:27:56 -0600

erogol2 gravatar image

updated 2015-06-10 12:31:36 -0600

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 flag offensive close merge delete

Comments

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

LorenaGdL gravatar imageLorenaGdL ( 2015-06-10 12:59:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-06-11 08:14:40 -0600

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.

edit flag offensive delete link more

Comments

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)

LorenaGdL gravatar imageLorenaGdL ( 2015-06-11 10:08:42 -0600 )edit

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

StevenPuttemans gravatar imageStevenPuttemans ( 2015-06-12 01:47:15 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-10 12:27:56 -0600

Seen: 431 times

Last updated: Jun 11 '15