HOGDescriptor returning wrong result in static image [closed]

asked 2014-05-30 21:06:19 -0500

Darren gravatar image

updated 2014-05-31 01:04:19 -0500

berak gravatar image

I am trying to detect the presence of human in a static image using OpenCV HOGDescriptor in Android.

Here is the Android java code, I couldn't find an example in Android online, I tried to port the example in C++ in peopledetect.cpp to it.

mHOGDescriptor = new HOGDescriptor();
Mat img = Highgui.imread(path);
final MatOfRect foundLocations = new MatOfRect();
final MatOfDouble foundWeights = new MatOfDouble();
final Size winStride = new Size(8, 8);
final Size padding = new Size(32, 32);

mHOGDescriptor.detectMultiScale(img, foundLocations, foundWeights, 0.0, winStride, padding, 1.05, 2.0, false);
Boolean withFace = false;
Rect[] array = foundLocations.toArray();
for (int j = 0; j < array.length; j++) {
    Rect rect = array[j];
    Log.i("TEST", "Height " + rect.height + ", Width " + rect.width);

When I test it again a small set of 30 photos, I notice that the number of false positive is very high. Some of the photos with no obvious person features are flagged as with person too. (in the foundLocation array above and the rect height and width are quite high)

For example, in the photo below, it's obvious that there is no human in it. But it detects with 2 persons, rects of height 375, width 187 and height 178, width 89

image description

Is there anything I can do to improve it?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-23 05:44:32.340147


What is the foundWeights's value for those windows? Your threshold might be too low. Try to increase it, test in this picture and in a picture with real persons to see if you won't lose anybody.

Yamaneko gravatar imageYamaneko ( 2014-05-31 10:32:39 -0500 )edit