Commit cc315c6901ee822f338ed77a85581a3465652c5b
1 parent
6b9a117b
Returning summed confidences in grouping
Showing
1 changed file
with
4 additions
and
3 deletions
openbr/core/opencvutils.cpp
| @@ -451,6 +451,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | @@ -451,6 +451,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | ||
| 451 | 451 | ||
| 452 | // Total number of rects in each class | 452 | // Total number of rects in each class |
| 453 | vector<int> neighbors(nClasses, 0); | 453 | vector<int> neighbors(nClasses, 0); |
| 454 | + vector<float> classConfidence(nClasses, 0); | ||
| 454 | vector<float> rejectWeights(nClasses, -std::numeric_limits<float>::max()); | 455 | vector<float> rejectWeights(nClasses, -std::numeric_limits<float>::max()); |
| 455 | 456 | ||
| 456 | for (size_t i = 0; i < labels.size(); i++) | 457 | for (size_t i = 0; i < labels.size(); i++) |
| @@ -461,6 +462,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | @@ -461,6 +462,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | ||
| 461 | rrects[cls].width += rects[i].width; | 462 | rrects[cls].width += rects[i].width; |
| 462 | rrects[cls].height += rects[i].height; | 463 | rrects[cls].height += rects[i].height; |
| 463 | neighbors[cls]++; | 464 | neighbors[cls]++; |
| 465 | + classConfidence[cls] += confidences[i]; | ||
| 464 | } | 466 | } |
| 465 | 467 | ||
| 466 | if (useConfidences) | 468 | if (useConfidences) |
| @@ -495,11 +497,10 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | @@ -495,11 +497,10 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | ||
| 495 | Rect r1 = rrects[i]; | 497 | Rect r1 = rrects[i]; |
| 496 | 498 | ||
| 497 | // Used to eliminate rectangles with few neighbors in the case of no weights | 499 | // Used to eliminate rectangles with few neighbors in the case of no weights |
| 498 | - // int n1 = levelWeights ? rejectLevels[i] : rweights[i]; | ||
| 499 | const float w1 = rejectWeights[i]; | 500 | const float w1 = rejectWeights[i]; |
| 500 | 501 | ||
| 501 | // Eliminate rectangle if it doesn't meet confidence criteria | 502 | // Eliminate rectangle if it doesn't meet confidence criteria |
| 502 | - if (w1 <= confidenceThreshold) | 503 | + if (w1 < confidenceThreshold) |
| 503 | continue; | 504 | continue; |
| 504 | 505 | ||
| 505 | const int n1 = neighbors[i]; | 506 | const int n1 = neighbors[i]; |
| @@ -536,7 +537,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | @@ -536,7 +537,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con | ||
| 536 | { | 537 | { |
| 537 | rects.append(r1); | 538 | rects.append(r1); |
| 538 | if (useConfidences) | 539 | if (useConfidences) |
| 539 | - confidences.append(w1); | 540 | + confidences.append(classConfidence[i]); |
| 540 | } | 541 | } |
| 541 | } | 542 | } |
| 542 | } | 543 | } |