Commit 0658fb418c4db064ec534f6c9976c6a7dc493849
1 parent
092deb04
update eval
Showing
2 changed files
with
11 additions
and
11 deletions
openbr/core/eval.cpp
| @@ -100,10 +100,10 @@ static cv::Mat constructMatchingMask(const cv::Mat &scores, const FileList &targ | @@ -100,10 +100,10 @@ static cv::Mat constructMatchingMask(const cv::Mat &scores, const FileList &targ | ||
| 100 | 100 | ||
| 101 | float Evaluate(const cv::Mat &scores, const FileList &target, const FileList &query, const QString &csv, int partition) | 101 | float Evaluate(const cv::Mat &scores, const FileList &target, const FileList &query, const QString &csv, int partition) |
| 102 | { | 102 | { |
| 103 | - return Evaluate(scores, constructMatchingMask(scores, target, query, partition), QString(), QString(), csv, 0); | 103 | + return Evaluate(scores, constructMatchingMask(scores, target, query, partition), csv, QString(), QString(), 0); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | -float Evaluate(const QString &simmat, const QString &mask, const QString &csv, int matches) | 106 | +float Evaluate(const QString &simmat, const QString &mask, const QString &csv, unsigned int matches) |
| 107 | { | 107 | { |
| 108 | qDebug("Evaluating %s%s%s", | 108 | qDebug("Evaluating %s%s%s", |
| 109 | qPrintable(simmat), | 109 | qPrintable(simmat), |
| @@ -137,12 +137,12 @@ float Evaluate(const QString &simmat, const QString &mask, const QString &csv, i | @@ -137,12 +137,12 @@ float Evaluate(const QString &simmat, const QString &mask, const QString &csv, i | ||
| 137 | truth = format->read(); | 137 | truth = format->read(); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | - return Evaluate(scores, truth, target, query, csv, matches); | 140 | + return Evaluate(scores, truth, csv, target, query, matches); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | -float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const QString &query, const QString &csv, int matches) | 143 | +float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv, const QString &target, const QString &query, unsigned int matches) |
| 144 | { | 144 | { |
| 145 | - if ((target.isEmpty() || query.isEmpty()) && matches != 0) matches = 0; | 145 | + if (target.isEmpty() || query.isEmpty()) matches = 0; |
| 146 | if (simmat.size() != mask.size()) | 146 | if (simmat.size() != mask.size()) |
| 147 | qFatal("Similarity matrix (%ix%i) differs in size from mask matrix (%ix%i).", | 147 | qFatal("Similarity matrix (%ix%i) differs in size from mask matrix (%ix%i).", |
| 148 | simmat.rows, simmat.cols, mask.rows, mask.cols); | 148 | simmat.rows, simmat.cols, mask.rows, mask.cols); |
| @@ -173,7 +173,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | @@ -173,7 +173,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | ||
| 173 | if (comparison.genuine) { | 173 | if (comparison.genuine) { |
| 174 | genuineCount++; | 174 | genuineCount++; |
| 175 | if (matches != 0){ | 175 | if (matches != 0){ |
| 176 | - if (botGenuines.size() < matches) { | 176 | + if (botGenuines.size() < (int)matches) { |
| 177 | botGenuines.append(comparison); | 177 | botGenuines.append(comparison); |
| 178 | std::sort(botGenuines.begin(), botGenuines.end()); | 178 | std::sort(botGenuines.begin(), botGenuines.end()); |
| 179 | } else if (comparison.score < botGenuines.first().score) { | 179 | } else if (comparison.score < botGenuines.first().score) { |
| @@ -185,7 +185,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | @@ -185,7 +185,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | ||
| 185 | } else { | 185 | } else { |
| 186 | impostorCount++; | 186 | impostorCount++; |
| 187 | if (matches != 0) { | 187 | if (matches != 0) { |
| 188 | - if (topImpostors.size() < matches) { | 188 | + if (topImpostors.size() < (int)matches) { |
| 189 | topImpostors.append(comparison); | 189 | topImpostors.append(comparison); |
| 190 | std::sort(topImpostors.begin(), topImpostors.end()); | 190 | std::sort(topImpostors.begin(), topImpostors.end()); |
| 191 | } else if (topImpostors.last().score < comparison.score) { | 191 | } else if (topImpostors.last().score < comparison.score) { |
| @@ -266,8 +266,8 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | @@ -266,8 +266,8 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &target, const | ||
| 266 | 266 | ||
| 267 | QString filePath = Globals->path; | 267 | QString filePath = Globals->path; |
| 268 | if (matches != 0) { | 268 | if (matches != 0) { |
| 269 | - FileList targetFiles = TemplateList::fromGallery(target).files(); | ||
| 270 | - FileList queryFiles = TemplateList::fromGallery(query).files(); | 269 | + const FileList targetFiles = TemplateList::fromGallery(target).files(); |
| 270 | + const FileList queryFiles = TemplateList::fromGallery(query).files(); | ||
| 271 | for (int i=0; i<topImpostors.size(); i++) { | 271 | for (int i=0; i<topImpostors.size(); i++) { |
| 272 | lines.append("TI,"+QString::number(topImpostors[i].score)+","+targetFiles[topImpostors[i].target].get<QString>("Label")+":" | 272 | lines.append("TI,"+QString::number(topImpostors[i].score)+","+targetFiles[topImpostors[i].target].get<QString>("Label")+":" |
| 273 | +filePath+"/"+targetFiles[topImpostors[i].target].name+":"+queryFiles[topImpostors[i].query].get<QString>("Label")+":"+filePath+"/"+queryFiles[topImpostors[i].query].name); | 273 | +filePath+"/"+targetFiles[topImpostors[i].target].name+":"+queryFiles[topImpostors[i].query].get<QString>("Label")+":"+filePath+"/"+queryFiles[topImpostors[i].query].name); |
openbr/core/eval.h
| @@ -23,9 +23,9 @@ | @@ -23,9 +23,9 @@ | ||
| 23 | 23 | ||
| 24 | namespace br | 24 | namespace br |
| 25 | { | 25 | { |
| 26 | - float Evaluate(const QString &simmat, const QString &mask = "", const QString &csv = "", int matches = 0); // Returns TAR @ FAR = 0.001 | 26 | + float Evaluate(const QString &simmat, const QString &mask = "", const QString &csv = "", unsigned int matches = 0); // Returns TAR @ FAR = 0.001 |
| 27 | float Evaluate(const cv::Mat &scores, const FileList &target, const FileList &query, const QString &csv = "", int parition = 0); | 27 | float Evaluate(const cv::Mat &scores, const FileList &target, const FileList &query, const QString &csv = "", int parition = 0); |
| 28 | - float Evaluate(const cv::Mat &scores, const cv::Mat &masks, const QString &target = "", const QString &query = "", const QString &csv = "", int matches = 0); | 28 | + float Evaluate(const cv::Mat &scores, const cv::Mat &masks, const QString &csv = "", const QString &target = "", const QString &query = "", unsigned int matches = 0); |
| 29 | float InplaceEval(const QString & simmat, const QString & target, const QString & query, const QString & csv = ""); | 29 | float InplaceEval(const QString & simmat, const QString & target, const QString & query, const QString & csv = ""); |
| 30 | 30 | ||
| 31 | void EvalClassification(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); | 31 | void EvalClassification(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); |