HOGDescriptor returning wrong result in static image [closed]
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
Is there anything I can do to improve it?
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.