diff --git a/app/br/br.cpp b/app/br/br.cpp index 20858b2..1dbe211 100644 --- a/app/br/br.cpp +++ b/app/br/br.cpp @@ -157,8 +157,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 <= 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); + check((parc >= 2) && (parc <= 6), "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, parc == 6 ? atoi(parv[5]) : 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 226fd5c..b93f998 100755 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -667,6 +667,7 @@ struct SortedDetection SortedDetection() : truth_idx(-1), predicted_idx(-1), overlap(-1) {} SortedDetection(int truth_idx_, int predicted_idx_, float overlap_) : truth_idx(truth_idx_), predicted_idx(predicted_idx_), overlap(overlap_) {} + inline bool operator<(const SortedDetection &other) const { return overlap > other.overlap; } }; struct Detections @@ -832,16 +833,11 @@ static QMap getDetections(const File &predictedGallery, con return allDetections; } -static int getNumberOfImages(const QMap detections) +static inline int getNumberOfImages(const QMap detections) { return detections.keys().size(); } -static bool sortedCompare(const SortedDetection &a, const SortedDetection &b) -{ - return a.overlap > b.overlap; -} - static int associateGroundTruthDetections(QList &resolved, QList &falseNegative, QMap &all, QRectF &offsets) { float dLeftTotal = 0.0, dRightTotal = 0.0, dTopTotal = 0.0, dBottomTotal = 0.0; @@ -871,7 +867,7 @@ static int associateGroundTruthDetections(QList &resolved, QL } } - std::sort(sortedDetections.begin(), sortedDetections.end(), sortedCompare); + std::sort(sortedDetections.begin(), sortedDetections.end()); QList removedTruth; QList removedPredicted; diff --git a/openbr/core/eval.h b/openbr/core/eval.h index ff47c7f..0519beb 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, int minSize = 0); // Return average overlap + float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false, int minSize = 0, int maxSize = 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 9a5ffff..4ca2c55 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, int minSize) +float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv, bool normalize, int minSize, int maxSize) { - return EvalDetection(predicted_gallery, truth_gallery, csv, normalize, minSize); + return EvalDetection(predicted_gallery, truth_gallery, csv, normalize, minSize, maxSize); } 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 9c197a3..bc23c09 100644 --- a/openbr/openbr.h +++ b/openbr/openbr.h @@ -197,7 +197,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, int minSize = 0); +BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", bool normalize = false, int minSize = 0, int maxSize = 0); /*! * \brief Evaluates and prints landmarking accuracy to terminal.