Commit b51e4c556bf9d1c20838129ce5c9933b5b2d65dd
1 parent
9f01003d
Exposed confidenceThreshold
Showing
3 changed files
with
10 additions
and
10 deletions
openbr/core/opencvutils.cpp
| ... | ... | @@ -400,7 +400,7 @@ public: |
| 400 | 400 | }; |
| 401 | 401 | |
| 402 | 402 | // TODO: Make sure case where no confidences are inputted works. |
| 403 | -void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float epsilon) | |
| 403 | +void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float confidenceThreshold, float epsilon) | |
| 404 | 404 | { |
| 405 | 405 | if (rects.empty()) |
| 406 | 406 | return; |
| ... | ... | @@ -415,7 +415,7 @@ void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float e |
| 415 | 415 | |
| 416 | 416 | // Total number of rects in each class |
| 417 | 417 | vector<int> rweights(nClasses, 0); |
| 418 | - vector<double> rejectWeights(nClasses, -std::numeric_limits<double>::max()); | |
| 418 | + vector<float> rejectWeights(nClasses, -std::numeric_limits<float>::max()); | |
| 419 | 419 | |
| 420 | 420 | for (int i = 0; i < labels.size(); i++) |
| 421 | 421 | { |
| ... | ... | @@ -452,8 +452,6 @@ void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float e |
| 452 | 452 | rects.clear(); |
| 453 | 453 | confidences.clear(); |
| 454 | 454 | |
| 455 | - const double threshold = 2; | |
| 456 | - | |
| 457 | 455 | // Aggregate by comparing average rectangles against other average rectangels |
| 458 | 456 | for (int i = 0; i < nClasses; i++) |
| 459 | 457 | { |
| ... | ... | @@ -462,17 +460,17 @@ void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float e |
| 462 | 460 | |
| 463 | 461 | // Used to eliminate rectangles with few neighbors in the case of no weights |
| 464 | 462 | // int n1 = levelWeights ? rejectLevels[i] : rweights[i]; |
| 465 | - double w1 = rejectWeights[i]; | |
| 463 | + float w1 = rejectWeights[i]; | |
| 466 | 464 | |
| 467 | 465 | // Eliminate rectangle if it doesn't meet confidence criteria |
| 468 | - if (w1 <= threshold) | |
| 466 | + if (w1 <= confidenceThreshold) | |
| 469 | 467 | continue; |
| 470 | 468 | |
| 471 | 469 | // filter out small face rectangles inside large rectangles |
| 472 | 470 | int j; |
| 473 | 471 | for (j = 0; j < nClasses; j++) |
| 474 | 472 | { |
| 475 | - double w2 = rejectWeights[j]; | |
| 473 | + float w2 = rejectWeights[j]; | |
| 476 | 474 | |
| 477 | 475 | if (j == i) |
| 478 | 476 | continue; |
| ... | ... | @@ -493,7 +491,7 @@ void OpenCVUtils::group(vector<Rect> &rects, vector<float> &confidences, float e |
| 493 | 491 | r1.y >= r2.y - dy && |
| 494 | 492 | r1.x + r1.width <= r2.x + r2.width + dx && |
| 495 | 493 | r1.y + r1.height <= r2.y + r2.height + dy && |
| 496 | - (w2 > std::max(threshold, w1))) | |
| 494 | + (w2 > std::max(confidenceThreshold, w1))) | |
| 497 | 495 | break; |
| 498 | 496 | } |
| 499 | 497 | ... | ... |
openbr/core/opencvutils.h
| ... | ... | @@ -99,7 +99,7 @@ namespace OpenCVUtils |
| 99 | 99 | float overlap(const QRectF &rect1, const QRectF &rect2); |
| 100 | 100 | |
| 101 | 101 | // Misc |
| 102 | - void group(std::vector<cv::Rect> &rects, std::vector<float> &confidences, float epsilon); | |
| 102 | + void group(std::vector<cv::Rect> &rects, std::vector<float> &confidences, float confidenceThreshold, float epsilon); | |
| 103 | 103 | |
| 104 | 104 | int getFourcc(); |
| 105 | 105 | } | ... | ... |
openbr/plugins/imgproc/slidingwindow.cpp
| ... | ... | @@ -40,6 +40,7 @@ class SlidingWindowTransform : public MetaTransform |
| 40 | 40 | Q_PROPERTY(int maxSize READ get_maxSize WRITE set_maxSize RESET reset_maxSize STORED false) |
| 41 | 41 | Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false) |
| 42 | 42 | Q_PROPERTY(int minNeighbors READ get_minNeighbors WRITE set_minNeighbors RESET reset_minNeighbors STORED false) |
| 43 | + Q_PROPERTY(float confidenceThreshold READ get_confidenceThreshold WRITE set_confidenceThreshold RESET reset_confidenceThreshold STORED false) | |
| 43 | 44 | Q_PROPERTY(float eps READ get_eps WRITE set_eps RESET reset_eps STORED false) |
| 44 | 45 | |
| 45 | 46 | Q_PROPERTY(QString model READ get_model WRITE set_model RESET reset_model STORED false) |
| ... | ... | @@ -49,6 +50,7 @@ class SlidingWindowTransform : public MetaTransform |
| 49 | 50 | BR_PROPERTY(int, maxSize, -1) |
| 50 | 51 | BR_PROPERTY(float, scaleFactor, 1.2) |
| 51 | 52 | BR_PROPERTY(int, minNeighbors, 5) |
| 53 | + BR_PROPERTY(float, confidenceThreshold, 2) | |
| 52 | 54 | BR_PROPERTY(float, eps, 0.2) |
| 53 | 55 | |
| 54 | 56 | BR_PROPERTY(QString, model, "") |
| ... | ... | @@ -132,7 +134,7 @@ class SlidingWindowTransform : public MetaTransform |
| 132 | 134 | } |
| 133 | 135 | } |
| 134 | 136 | |
| 135 | - OpenCVUtils::group(rects, confidences, eps); | |
| 137 | + OpenCVUtils::group(rects, confidences, confidenceThreshold, eps); | |
| 136 | 138 | |
| 137 | 139 | if (!enrollAll && rects.empty()) |
| 138 | 140 | rects.push_back(Rect(0, 0, m.cols, m.rows)); | ... | ... |