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 | 451 | |
| 452 | 452 | // Total number of rects in each class |
| 453 | 453 | vector<int> neighbors(nClasses, 0); |
| 454 | + vector<float> classConfidence(nClasses, 0); | |
| 454 | 455 | vector<float> rejectWeights(nClasses, -std::numeric_limits<float>::max()); |
| 455 | 456 | |
| 456 | 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 | 462 | rrects[cls].width += rects[i].width; |
| 462 | 463 | rrects[cls].height += rects[i].height; |
| 463 | 464 | neighbors[cls]++; |
| 465 | + classConfidence[cls] += confidences[i]; | |
| 464 | 466 | } |
| 465 | 467 | |
| 466 | 468 | if (useConfidences) |
| ... | ... | @@ -495,11 +497,10 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con |
| 495 | 497 | Rect r1 = rrects[i]; |
| 496 | 498 | |
| 497 | 499 | // Used to eliminate rectangles with few neighbors in the case of no weights |
| 498 | - // int n1 = levelWeights ? rejectLevels[i] : rweights[i]; | |
| 499 | 500 | const float w1 = rejectWeights[i]; |
| 500 | 501 | |
| 501 | 502 | // Eliminate rectangle if it doesn't meet confidence criteria |
| 502 | - if (w1 <= confidenceThreshold) | |
| 503 | + if (w1 < confidenceThreshold) | |
| 503 | 504 | continue; |
| 504 | 505 | |
| 505 | 506 | const int n1 = neighbors[i]; |
| ... | ... | @@ -536,7 +537,7 @@ void OpenCVUtils::group(QList<Rect> &rects, QList<float> &confidences, float con |
| 536 | 537 | { |
| 537 | 538 | rects.append(r1); |
| 538 | 539 | if (useConfidences) |
| 539 | - confidences.append(w1); | |
| 540 | + confidences.append(classConfidence[i]); | |
| 540 | 541 | } |
| 541 | 542 | } |
| 542 | 543 | } | ... | ... |