GNOME Bugzilla – Bug 722158
facedetect: element non-functional because of unreasonable, hardcoded max-size setting
Last modified: 2014-01-14 12:06:21 UTC
Created attachment 266229 [details] [review] disable maximum object size restriction Some time ago I found that the facedetect element had stopped finding faces in my videos. I don't know when, exactly, this happened, but the problem hasn't resolved itself and I was finally motivated to see if I could figure out why. I think I've identified the cause, or at least I have a patch that fixes it for me locally. The gst_face_detect_run_detector() function includes an #if/#endif block that adds an extra argument to the cvHaarDetectObjects() call if the libopencv version is >= 2.2. Checking the documentation at http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html that final argument is described as "maxSize – Maximum possible object size. Objects larger than that are ignored". The gstreamer facedetect element sets this argument to cvSize (min_size_width + 2, min_size_height + 2) i.e., it hard-codes it to 2 pixels larger in width and height than the minimum object size. This seems to explain why the element can't find faces: unless the user sets the minimum object size to within a few pixels of the actual size of the faces in the video they will not be found. I have experimented and found that setting this parameter (0,0) seems to disable the max object size restriction, allowing faces to be detected once again. This is not documented in the libopencv documentation, so who knows, but I've attached a patch that makes this change. Note that faceblur hard-codes the maximum object size to 32x32 and also fails to find faces in my videos (which are recorded at 640x480). I recommend setting the parameter to 0x0 in that element as well.
commit e8d569f54de1af7f788a7ecb33fbb91e01a2f098 Author: Sebastian Dröge <sebastian@centricular.com> Date: Tue Jan 14 10:38:37 2014 +0100 faceblur: set maximum feature size to 0x0 Previously faces would only be detected if they were at least 30x30 pixels large and at most 32x32 pixels. We keep the minimum setting (maybe needs a property as in facedetect) but disable the maximum feature size. See https://bugzilla.gnome.org/show_bug.cgi?id=722158 commit b33b1390cc0d8fa242b739d5bcde1320ad6d50ff Author: Kipp Cannon <kcannon@cita.utoronto.ca> Date: Tue Jan 14 01:06:02 2014 -0500 facedetect: set maximum feature size to 0x0 This disables the "max feature size" feature. The current configuration is totally busted: The max feature size is hard-coded to 2 pixels more than the user-supplied min feature size which pretty much means you need to guess the size of the person's face to within a few pixels to get the code to find it. https://bugzilla.gnome.org/show_bug.cgi?id=722158