c++opencvopencv3.0cascade-classifier

DetectMultiScale never returns when calling overload with rejectLevels and levelWeights


I am trying to modify my OpenCV-based code to get confidences along with each detected object from a cascade classifier. When I call the overload of the CascadeClassifier's detectMultiScale method which takes out parameters for rejectLevels and levelWeights (and pass true for outputRejectLevels), the call never completes. Internally, the call to detectMultiScaleNoGrouping finishes quickly but returns millions of objects. When I don't pass either of the extra out parameters and set outputRejectLevels to false, that same call returns 60 object and the rest of the function works fine.

Am I not supposed to call this overload? Or is there a different reason that it is returning so many values that the function never finishes? How can I do this correctly?

Note: I see another question that appears to be referencing the same problem, but it does not include much information about the problem itself and hasn't gotten any answers.


Solution

  • It turns out that this has been fixed in OpenCV's master branch, but not released yet (as of April 18, 2016). I have confirmed that manually applying the patch and rebuilding fixes the problem.

    The relevant discussion is here and the PR that must be included to fix the problem is this one. It is a one-line change, so it should be easy to manually implement until they release an official build with the change included.