Comparing rejected stage index with minimum required neighbors does not make sense
authorAchal Dave <achalddave@live.com>
Sat, 1 Jun 2013 00:34:20 +0000 (18:34 -0600)
committerAchal Dave <achalddave@live.com>
Wed, 14 Aug 2013 03:42:04 +0000 (20:42 -0700)
As described here, http://code.opencv.org/issues/3064, the test before
led to a case where we compared the index of the latest stage at which a
rectangle was rejected with the minimum number of neighbors required as
specified in `detectMultiScale`. Please see the issue for more
information.

modules/objdetect/src/cascadedetect.cpp

index 9373f1c..2be6f1b 100644 (file)
@@ -196,8 +196,11 @@ void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps
     for( i = 0; i < nclasses; i++ )
     {
         Rect r1 = rrects[i];
-        int n1 = levelWeights ? rejectLevels[i] : rweights[i];
+        int n1 = rweights[i];
         double w1 = rejectWeights[i];
+        int l1 = rejectLevels[i];
+    
+        // filter out rectangles which don't have enough similar rectangles
         if( n1 <= groupThreshold )
             continue;
         // filter out small face rectangles inside large rectangles
@@ -225,7 +228,7 @@ void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps
         {
             rectList.push_back(r1);
             if( weights )
-                weights->push_back(n1);
+                weights->push_back(l1);
             if( levelWeights )
                 levelWeights->push_back(w1);
         }
@@ -988,7 +991,7 @@ public:
                 {
                     if( result == 1 )
                         result =  -(int)classifier->data.stages.size();
-                    if( classifier->data.stages.size() + result < 4 )
+                    if( classifier->data.stages.size() + result == 0 )
                     {
                         mtx->lock();
                         rectangles->push_back(Rect(cvRound(x*scalingFactor), cvRound(y*scalingFactor), winSize.width, winSize.height));