From 8a62b8b45caa0b9f7dc9b632e278b6b5ad7a0e22 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 18 Nov 2015 08:51:09 -0500 Subject: [PATCH] group cleanup --- openbr/core/opencvutils.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/openbr/core/opencvutils.cpp b/openbr/core/opencvutils.cpp index 69ef9a8..d1a0981 100644 --- a/openbr/core/opencvutils.cpp +++ b/openbr/core/opencvutils.cpp @@ -441,8 +441,6 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con if (rects.isEmpty()) return; - const bool useConfidences = !confidences.isEmpty(); - vector labels; int nClasses = cv::partition(rects.toVector().toStdVector(), labels, SimilarRects(epsilon)); @@ -452,7 +450,6 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con // Total number of rects in each class vector neighbors(nClasses, 0); vector classConfidence(nClasses, 0); - vector rejectWeights(nClasses, -std::numeric_limits::max()); for (size_t i = 0; i < labels.size(); i++) { @@ -465,17 +462,6 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con classConfidence[cls] += confidences[i]; } - if (useConfidences) - { - // For each class, find maximum confidence - for (size_t i = 0; i < labels.size(); i++) - { - int cls = labels[i]; - if (confidences[i] > rejectWeights[cls]) - rejectWeights[cls] = confidences[i]; - } - } - // Find average rectangle for all classes for (int i = 0; i < nClasses; i++) { @@ -497,7 +483,7 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con Rect r1 = rrects[i]; // Used to eliminate rectangles with few neighbors in the case of no weights - const float w1 = rejectWeights[i]; + const float w1 = classConfidence[i]; // Eliminate rectangle if it doesn't meet confidence criteria if (w1 < confidenceThreshold) @@ -520,7 +506,7 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con int dx = saturate_cast(r2.width * epsilon); int dy = saturate_cast(r2.height * epsilon); - float w2 = rejectWeights[j]; + float w2 = classConfidence[j]; // If, r1 is within the r2 AND // r2 has a higher confidence than r1 @@ -536,8 +522,7 @@ void OpenCVUtils::group(QList &rects, QList &confidences, float con if( j == nClasses ) { rects.append(r1); - if (useConfidences) - confidences.append(classConfidence[i]); + confidences.append(w1); } } } -- libgit2 0.21.4