Ask Your Question

Darren's profile - activity

2014-05-30 21:06:19 -0600 asked a question HOGDescriptor returning wrong result in static 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();
mHOGDescriptor.setSVMDetector(HOGDescriptor.getDefaultPeopleDetector());
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?