Commit 9d511ca71bd25eea9593ce9a00cf010fdaf4f7f0
Merge pull request #221 from biometrics/evalDetection
Merged!
Showing
5 changed files
with
26 additions
and
8 deletions
app/br/br.cpp
| ... | ... | @@ -144,8 +144,8 @@ public: |
| 144 | 144 | check((parc >= 2) && (parc <= 3), "Incorrect parameter count for 'evalClustering'."); |
| 145 | 145 | br_eval_clustering(parv[0], parv[1], parc == 3 ? parv[2] : ""); |
| 146 | 146 | } else if (!strcmp(fun, "evalDetection")) { |
| 147 | - check((parc >= 2) && (parc <= 4), "Incorrect parameter count for 'evalDetection'."); | |
| 148 | - br_eval_detection(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc == 4 ? atoi(parv[3]) : 0); | |
| 147 | + check((parc >= 2) && (parc <= 5), "Incorrect parameter count for 'evalDetection'."); | |
| 148 | + br_eval_detection(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc == 5 ? atoi(parv[4]) : 0); | |
| 149 | 149 | } else if (!strcmp(fun, "evalLandmarking")) { |
| 150 | 150 | check((parc >= 2) && (parc <= 5), "Incorrect parameter count for 'evalLandmarking'."); |
| 151 | 151 | br_eval_landmarking(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc >= 5 ? atoi(parv[4]) : 1); |
| ... | ... | @@ -247,7 +247,7 @@ private: |
| 247 | 247 | "-convert (Format|Gallery|Output) <input_file> {output_file}\n" |
| 248 | 248 | "-evalClassification <predicted_gallery> <truth_gallery> <predicted property name> <ground truth proprty name>\n" |
| 249 | 249 | "-evalClustering <clusters> <gallery>\n" |
| 250 | - "-evalDetection <predicted_gallery> <truth_gallery> [{csv}]\n" | |
| 250 | + "-evalDetection <predicted_gallery> <truth_gallery> [{csv}] [{minSize}]\n" | |
| 251 | 251 | "-evalLandmarking <predicted_gallery> <truth_gallery> [{csv} [<normalization_index_a> <normalization_index_b>]]\n" |
| 252 | 252 | "-evalRegression <predicted_gallery> <truth_gallery> <predicted property name> <ground truth property name>\n" |
| 253 | 253 | "-plotDetection <file> ... <file> {destination}\n" | ... | ... |
openbr/core/eval.cpp
| ... | ... | @@ -815,12 +815,30 @@ static int associateGroundTruthDetections(QList<ResolvedDetection> &resolved, QL |
| 815 | 815 | return totalTrueDetections; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | -float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv, bool normalize) | |
| 818 | +float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv, bool normalize, int minSize) | |
| 819 | 819 | { |
| 820 | 820 | qDebug("Evaluating detection of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); |
| 821 | 821 | // Organized by file, QMap used to preserve order |
| 822 | 822 | QMap<QString, Detections> allDetections = getDetections(predictedGallery, truthGallery); |
| 823 | 823 | |
| 824 | + // Remove any bounding boxes with a side smaller than minSize | |
| 825 | + if (minSize > 0) { | |
| 826 | + qDebug("Removing boxes smaller than %d\n", minSize); | |
| 827 | + foreach(QString key, allDetections.keys()) { | |
| 828 | + Detections detections = allDetections[key]; | |
| 829 | + for (int i = 0; i < detections.predicted.length(); i++) { | |
| 830 | + QRectF box = detections.predicted[i].boundingBox; | |
| 831 | + if (min(box.width(), box.height()) < minSize) | |
| 832 | + detections.predicted.removeAt(i); | |
| 833 | + } | |
| 834 | + for (int i = 0; i < detections.truth.length(); i++) { | |
| 835 | + QRectF box = detections.truth[i].boundingBox; | |
| 836 | + if (min(box.width(), box.height()) < minSize) | |
| 837 | + detections.truth.removeAt(i); | |
| 838 | + } | |
| 839 | + } | |
| 840 | + } | |
| 841 | + | |
| 824 | 842 | QList<ResolvedDetection> resolvedDetections, falseNegativeDetections; |
| 825 | 843 | QRectF normalizations(0, 0, 0, 0); |
| 826 | 844 | ... | ... |
openbr/core/eval.h
| ... | ... | @@ -29,7 +29,7 @@ namespace br |
| 29 | 29 | float InplaceEval(const QString & simmat, const QString & target, const QString & query, const QString & csv = ""); |
| 30 | 30 | |
| 31 | 31 | void EvalClassification(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); |
| 32 | - float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false); // Return average overlap | |
| 32 | + float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false, int minSize = 0); // Return average overlap | |
| 33 | 33 | float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1); // Return average error |
| 34 | 34 | void EvalRegression(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); |
| 35 | 35 | } | ... | ... |
openbr/openbr.cpp
| ... | ... | @@ -124,9 +124,9 @@ void br_eval_clustering(const char *csv, const char *gallery, const char *truth_ |
| 124 | 124 | EvalClustering(csv, gallery, truth_property); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv, bool normalize) | |
| 127 | +float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv, bool normalize, int minSize) | |
| 128 | 128 | { |
| 129 | - return EvalDetection(predicted_gallery, truth_gallery, csv, normalize); | |
| 129 | + return EvalDetection(predicted_gallery, truth_gallery, csv, normalize, minSize); | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv, int normalization_index_a, int normalization_index_b) | ... | ... |
openbr/openbr.h
| ... | ... | @@ -196,7 +196,7 @@ BR_EXPORT void br_eval_clustering(const char *csv, const char *gallery, const ch |
| 196 | 196 | * \param normalize Optional \c bool flag to normalize predicted bounding boxes for improved detection. |
| 197 | 197 | * \return Average detection bounding box overlap. |
| 198 | 198 | */ |
| 199 | -BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", bool normalize = false); | |
| 199 | +BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", bool normalize = false, int minSize = 0); | |
| 200 | 200 | |
| 201 | 201 | /*! |
| 202 | 202 | * \brief Evaluates and prints landmarking accuracy to terminal. | ... | ... |