Commit f062aec462fcae28db71531acb70947b5bfe1cc2
1 parent
dc7363e1
Added control to number of examples
Showing
6 changed files
with
15 additions
and
13 deletions
app/br/br.cpp
| ... | ... | @@ -163,8 +163,8 @@ public: |
| 163 | 163 | check((parc >= 2) && (parc <= 6), "Incorrect parameter count for 'evalDetection'."); |
| 164 | 164 | 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); |
| 165 | 165 | } else if (!strcmp(fun, "evalLandmarking")) { |
| 166 | - check((parc >= 2) && (parc <= 6), "Incorrect parameter count for 'evalLandmarking'."); | |
| 167 | - br_eval_landmarking(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc >= 5 ? atoi(parv[4]) : 1, parc >= 6 ? atoi(parv[5]) : 0); | |
| 166 | + check((parc >= 2) && (parc <= 7), "Incorrect parameter count for 'evalLandmarking'."); | |
| 167 | + br_eval_landmarking(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? atoi(parv[3]) : 0, parc >= 5 ? atoi(parv[4]) : 1, parc >= 6 ? atoi(parv[5]) : 0, parc >= 7 ? atoi(parv[6]) : 5); | |
| 168 | 168 | } else if (!strcmp(fun, "evalRegression")) { |
| 169 | 169 | check(parc >= 2 && parc <= 4, "Incorrect parameter count for 'evalRegression'."); |
| 170 | 170 | br_eval_regression(parv[0], parv[1], parc >= 3 ? parv[2] : "", parc >= 4 ? parv[3] : ""); | ... | ... |
openbr/core/eval.cpp
| ... | ... | @@ -1040,7 +1040,7 @@ static void projectAndWrite(Transform *t, const Template &src, const QString &fi |
| 1040 | 1040 | OpenCVUtils::saveImage(dst.m(),filePath); |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | -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, int totalExamples) | |
| 1044 | 1044 | { |
| 1045 | 1045 | qDebug("Evaluating landmarking of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); |
| 1046 | 1046 | TemplateList predicted(TemplateList::fromGallery(predictedGallery)); |
| ... | ... | @@ -1109,7 +1109,6 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle |
| 1109 | 1109 | |
| 1110 | 1110 | QScopedPointer<Transform> t(Transform::make("Open+Draw(rects=false)",NULL)); |
| 1111 | 1111 | |
| 1112 | - const int totalExamples = 10; | |
| 1113 | 1112 | for (int i=0; i<totalExamples; i++) { |
| 1114 | 1113 | QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName(); |
| 1115 | 1114 | projectAndWrite(t.data(), truth[exampleIndices[i].second],filePath); | ... | ... |
openbr/core/eval.h
| ... | ... | @@ -31,7 +31,7 @@ namespace br |
| 31 | 31 | |
| 32 | 32 | void EvalClassification(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); |
| 33 | 33 | float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", bool normalize = false, int minSize = 0, int maxSize = 0); // Return average overlap |
| 34 | - float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1, int sampleIndex = 0); // Return average error | |
| 34 | + float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1, int sampleIndex = 0, int totalExamples = 5); // Return average error | |
| 35 | 35 | void EvalRegression(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); |
| 36 | 36 | } |
| 37 | 37 | ... | ... |
openbr/core/plot.cpp
| ... | ... | @@ -546,11 +546,13 @@ bool PlotLandmarking(const QStringList &files, const File &destination, bool sho |
| 546 | 546 | "algs <- unique(Box$%1)\n" |
| 547 | 547 | "algs <- algs[!duplicated(algs)]\n" |
| 548 | 548 | "print(plotImage(sample[[1]],\"Sample Landmarks\",sprintf(\"Total Landmarks: %s\",sample[[1]]$value))) \n" |
| 549 | - "for (j in 1:length(algs)) {\n" | |
| 550 | - "truthSample <- readData(EXT[EXT$. == algs[[j]],])\n" | |
| 551 | - "predictedSample <- readData(EXP[EXP$. == algs[[j]],])\n" | |
| 552 | - "\tfor (i in 1:length(predictedSample)) {\n" | |
| 553 | - "\t\tmultiplot(plotImage(predictedSample[[i]],sprintf(\"%s\\nPredicted Landmarks\",algs[[j]]),sprintf(\"Average Landmark Error: %.3f\",predictedSample[[i]]$value)),plotImage(truthSample[[i]],\"Ground Truth\\nLandmarks\",\"\"),cols=2)\n" | |
| 549 | + "if (nrow(EXT) != 0 && nrow(EXP)) {\n" | |
| 550 | + "\tfor (j in 1:length(algs)) {\n" | |
| 551 | + "\ttruthSample <- readData(EXT[EXT$. == algs[[j]],])\n" | |
| 552 | + "\tpredictedSample <- readData(EXP[EXP$. == algs[[j]],])\n" | |
| 553 | + "\t\tfor (i in 1:length(predictedSample)) {\n" | |
| 554 | + "\t\t\tmultiplot(plotImage(predictedSample[[i]],sprintf(\"%s\\nPredicted Landmarks\",algs[[j]]),sprintf(\"Average Landmark Error: %.3f\",predictedSample[[i]]$value)),plotImage(truthSample[[i]],\"Ground Truth\\nLandmarks\",\"\"),cols=2)\n" | |
| 555 | + "\t\t}\n" | |
| 554 | 556 | "\t}\n" |
| 555 | 557 | "}\n").arg(p.major.size > 1 ? p.major.header : (p.minor.header.isEmpty() ? p.major.header : p.minor.header)))); |
| 556 | 558 | ... | ... |
openbr/openbr.cpp
| ... | ... | @@ -134,9 +134,9 @@ float br_eval_detection(const char *predicted_gallery, const char *truth_gallery |
| 134 | 134 | return EvalDetection(predicted_gallery, truth_gallery, csv, normalize, minSize, maxSize); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv, int normalization_index_a, int normalization_index_b, int sample_index) | |
| 137 | +float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv, int normalization_index_a, int normalization_index_b, int sample_index, int total_examples) | |
| 138 | 138 | { |
| 139 | - return EvalLandmarking(predicted_gallery, truth_gallery, csv, normalization_index_a, normalization_index_b, sample_index); | |
| 139 | + return EvalLandmarking(predicted_gallery, truth_gallery, csv, normalization_index_a, normalization_index_b, sample_index, total_examples); | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | void br_eval_regression(const char *predicted_gallery, const char *truth_gallery, const char *predicted_property, const char *truth_property) | ... | ... |
openbr/openbr.h
| ... | ... | @@ -215,8 +215,9 @@ BR_EXPORT float br_eval_detection(const char *predicted_gallery, const char *tru |
| 215 | 215 | * \param normalization_index_a Optional first index in the list of points to use for normalization. |
| 216 | 216 | * \param normalization_index_b Optional second index in the list of points to use for normalization. |
| 217 | 217 | * \param sample_index Optional index for sample landmark image in ground truth gallery. |
| 218 | + * \param total_examples Optional number of accurate and inaccurate examples to display. | |
| 218 | 219 | */ |
| 219 | -BR_EXPORT float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", int normalization_index_a = 0, int normalization_index_b = 1, int sample_index = 0); | |
| 220 | +BR_EXPORT float br_eval_landmarking(const char *predicted_gallery, const char *truth_gallery, const char *csv = "", int normalization_index_a = 0, int normalization_index_b = 1, int sample_index = 0, int total_examples = 5); | |
| 220 | 221 | |
| 221 | 222 | /*! |
| 222 | 223 | * \brief Evaluates regression accuracy to disk. | ... | ... |