From 50975d83aa9ed0f94509f45c2f6a743078723f5a Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Jul 2014 15:29:05 -0400 Subject: [PATCH] Change filter to minSize and brought up-to-date with master --- app/br/br.cpp | 4 ++-- openbr/core/eval.cpp | 18 +++++++++++++++++- openbr/core/eval.h | 2 +- openbr/openbr.cpp | 4 ++-- openbr/openbr.h | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/br/br.cpp b/app/br/br.cpp index b19982f..507f974 100644 --- a/app/br/br.cpp +++ b/app/br/br.cpp @@ -144,8 +144,8 @@ public: check((parc >= 2) && (parc <= 3), "Incorrect parameter count for 'evalClustering'."); br_eval_clustering(parv[0], parv[1], parc == 3 ? parv[2] : ""); } else if (!strcmp(fun, "evalDetection")) { - check((parc >= 2) && (parc <= 4), "Incorrect parameter count for 'evalDetection'."); - br_eval_detection(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc == 4 ? atoi(parv[3]) : 0); + check((parc >= 2) && (parc <= 5), "Incorrect parameter count for 'evalDetection'."); + br_eval_detection(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc == 5 ? atoi(parv[4]) : 0); } else if (!strcmp(fun, "evalLandmarking")) { check((parc >= 2) && (parc <= 5), "Incorrect parameter count for 'evalLandmarking'."); br_eval_landmarking(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc >= 5 ? atoi(parv[4]) : 1); diff --git a/openbr/core/eval.cpp b/openbr/core/eval.cpp index a0e8e68..e0c45b2 100644 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -815,11 +815,27 @@ static int associateGroundTruthDetections(QList &resolved, QL return totalTrueDetections; } -float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv, bool normalize) +float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv, bool normalize, int minSize) { qDebug("Evaluating detection of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); // Organized by file, QMap used to preserve order QMap allDetections = getDetections(predictedGallery, truthGallery); + + // Remove any bounding boxes with a side smaller than minSize + if (minSize > 0) { + foreach(QString key, allDetections.keys()) { + for (int i = 0; i < allDetections[key].predicted.length(); i++) { + QRectF box = allDetections[key].predicted[i].boundingBox; + if (min(box.width(), box.height()) < minSize) + allDetections[key].predicted.removeAt(i); + } + for (int i = 0; i < allDetections[key].truth.length(); i++) { + QRectF box = allDetections[key].truth[i].boundingBox; + if (min(box.width(), box.height()) < minSize) + allDetections[key].truth.removeAt(i); + } + } + } QList resolvedDetections, falseNegativeDetections; QRectF normalizations(0, 0, 0, 0); diff --git a/openbr/core/eval.h b/openbr/core/eval.h index a8c40e6..d62c8c0 100644 --- a/openbr/core/eval.h +++ b/openbr/core/eval.h @@ -29,7 +29,7 @@ namespace br float InplaceEval(const QString & simmat, const QString & target, const QString & query, const QString & csv = ""); void EvalClassification(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); - float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false); // Return average overlap + float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false, int minSize = 0); // Return average overlap float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1); // Return average error void EvalRegression(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); } diff --git a/openbr/openbr.cpp b/openbr/openbr.cpp index f1a3ae4..ddac0a7 100644 --- a/openbr/openbr.cpp +++ b/openbr/openbr.cpp @@ -124,9 +124,9 @@ void br_eval_clustering(const char *csv, const char *gallery, const char *truth_ EvalClustering(csv, gallery, truth_property); } -float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv, bool normalize) +float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv, bool normalize, int minSize) { - return EvalDetection(predicted_gallery, truth_gallery, csv, normalize); + return EvalDetection(predicted_gallery, truth_gallery, csv, normalize, minSize); } float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv, int normalization_index_a, int normalization_index_b) diff --git a/openbr/openbr.h b/openbr/openbr.h index 33c4a7b..518303a 100644 --- a/openbr/openbr.h +++ b/openbr/openbr.h @@ -196,7 +196,7 @@ BR_EXPORT void br_eval_clustering(const char *csv, const char *gallery, const ch * \param normalize Optional \c bool flag to normalize predicted bounding boxes for improved detection. * \return Average detection bounding box overlap. */ -BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", bool normalize = false); +BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", bool normalize = false, int minSize); /*! * \brief Evaluates and prints landmarking accuracy to terminal. -- libgit2 0.21.4