Commit dc7363e18cbcd40c6b6bc2e3094167a246a5cdd1
1 parent
c9845813
Added convenience projectAndWrite function
Showing
1 changed file
with
28 additions
and
22 deletions
openbr/core/eval.cpp
| @@ -1033,6 +1033,13 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | @@ -1033,6 +1033,13 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery | ||
| 1033 | return averageOverlap; | 1033 | return averageOverlap; |
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | +static void projectAndWrite(Transform *t, const Template &src, const QString &filePath) | ||
| 1037 | +{ | ||
| 1038 | + Template dst; | ||
| 1039 | + t->project(src,dst); | ||
| 1040 | + OpenCVUtils::saveImage(dst.m(),filePath); | ||
| 1041 | +} | ||
| 1042 | + | ||
| 1036 | float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv, int normalizationIndexA, int normalizationIndexB, int sampleIndex) | 1043 | float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv, int normalizationIndexA, int normalizationIndexB, int sampleIndex) |
| 1037 | { | 1044 | { |
| 1038 | qDebug("Evaluating landmarking of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); | 1045 | qDebug("Evaluating landmarking of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); |
| @@ -1089,39 +1096,38 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -1089,39 +1096,38 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 1089 | QtUtils::touchDir(QDir("landmarking_examples_predicted")); | 1096 | QtUtils::touchDir(QDir("landmarking_examples_predicted")); |
| 1090 | 1097 | ||
| 1091 | // Example | 1098 | // Example |
| 1092 | - Transform *t = Transform::make("Open+Draw(verbose,rects=false,location=false)",NULL); | 1099 | + { |
| 1100 | + QScopedPointer<Transform> t(Transform::make("Open+Draw(verbose,rects=false,location=false)",NULL)); | ||
| 1093 | 1101 | ||
| 1094 | - Template drawn; | ||
| 1095 | - t->project(truth[sampleIndex],drawn); | ||
| 1096 | - OpenCVUtils::saveImage(drawn.m(),"landmarking_examples_truth/"+drawn.file.fileName()); | ||
| 1097 | - lines.append("Sample,landmarking_examples_truth/"+truth[sampleIndex].file.fileName()+","+QString::number(truth[sampleIndex].file.points().size())); | 1102 | + QString filePath = "landmarking_examples_truth/"+truth[sampleIndex].file.fileName(); |
| 1103 | + projectAndWrite(t.data(), truth[sampleIndex],filePath); | ||
| 1104 | + lines.append("Sample,"+filePath+","+QString::number(truth[sampleIndex].file.points().size())); | ||
| 1105 | + } | ||
| 1098 | 1106 | ||
| 1099 | // Get best and worst performing examples | 1107 | // Get best and worst performing examples |
| 1100 | QList< QPair<float,int> > exampleIndices = Common::Sort(imageErrors,true); | 1108 | QList< QPair<float,int> > exampleIndices = Common::Sort(imageErrors,true); |
| 1101 | 1109 | ||
| 1102 | - Transform *t2 = Transform::make("Open+Draw(rects=false)",NULL); | 1110 | + QScopedPointer<Transform> t(Transform::make("Open+Draw(rects=false)",NULL)); |
| 1103 | 1111 | ||
| 1104 | const int totalExamples = 10; | 1112 | const int totalExamples = 10; |
| 1105 | for (int i=0; i<totalExamples; i++) { | 1113 | for (int i=0; i<totalExamples; i++) { |
| 1106 | - Template truthDrawn; | ||
| 1107 | - t2->project(truth[exampleIndices[i].second],truthDrawn); | ||
| 1108 | - OpenCVUtils::saveImage(truthDrawn.m(),"landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName()); | ||
| 1109 | - lines.append("EXT,landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName()+","+QString::number(exampleIndices[i].first)); | ||
| 1110 | - Template predictedDrawn; | ||
| 1111 | - t2->project(predicted[exampleIndices[i].second],predictedDrawn); | ||
| 1112 | - OpenCVUtils::saveImage(predictedDrawn.m(),"landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName()); | ||
| 1113 | - lines.append("EXP,landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName()+","+QString::number(exampleIndices[i].first)); | 1114 | + QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName(); |
| 1115 | + projectAndWrite(t.data(), truth[exampleIndices[i].second],filePath); | ||
| 1116 | + lines.append("EXT,"+filePath+","+QString::number(exampleIndices[i].first)); | ||
| 1117 | + | ||
| 1118 | + filePath = "landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName(); | ||
| 1119 | + projectAndWrite(t.data(), predicted[exampleIndices[i].second],filePath); | ||
| 1120 | + lines.append("EXP,"+filePath+","+QString::number(exampleIndices[i].first)); | ||
| 1114 | } | 1121 | } |
| 1115 | 1122 | ||
| 1116 | for (int i=exampleIndices.size()-1; i>exampleIndices.size()-totalExamples-1; i--) { | 1123 | for (int i=exampleIndices.size()-1; i>exampleIndices.size()-totalExamples-1; i--) { |
| 1117 | - Template truthDrawn; | ||
| 1118 | - t2->project(truth[exampleIndices[i].second],truthDrawn); | ||
| 1119 | - OpenCVUtils::saveImage(truthDrawn.m(),"landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName()); | ||
| 1120 | - lines.append("EXT,landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName()+","+QString::number(exampleIndices[i].first)); | ||
| 1121 | - Template predictedDrawn; | ||
| 1122 | - t2->project(predicted[exampleIndices[i].second],predictedDrawn); | ||
| 1123 | - OpenCVUtils::saveImage(predictedDrawn.m(),"landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName()); | ||
| 1124 | - lines.append("EXP,landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName()+","+QString::number(exampleIndices[i].first)); | 1124 | + QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName(); |
| 1125 | + projectAndWrite(t.data(), truth[exampleIndices[i].second],filePath); | ||
| 1126 | + lines.append("EXT,"+filePath+","+QString::number(exampleIndices[i].first)); | ||
| 1127 | + | ||
| 1128 | + filePath = "landmarking_examples_predicted/"+predicted[exampleIndices[i].second].file.fileName(); | ||
| 1129 | + projectAndWrite(t.data(), predicted[exampleIndices[i].second],filePath); | ||
| 1130 | + lines.append("EXP,"+filePath+","+QString::number(exampleIndices[i].first)); | ||
| 1125 | } | 1131 | } |
| 1126 | 1132 | ||
| 1127 | for (int i=0; i<pointErrors.size(); i++) { | 1133 | for (int i=0; i<pointErrors.size(); i++) { |