Commit 2629448a64e0f7acf8cc0c1f9e532f399e8711fd

Authored by Ben Klein
2 parents 56197f41 f6ae8cdf

Merge pull request #269 from biometrics/eval

Add template size table to BR plotting
openbr/core/eval.cpp
@@ -310,6 +310,14 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv, const QSt @@ -310,6 +310,14 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv, const QSt
310 lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); 310 lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3))));
311 lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3)))); 311 lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3))));
312 312
  313 + // Attempt to read template size from enrolled gallery and write to output CSV
  314 + size_t maxSize(0);
  315 + if (target.endsWith(".gal")) {
  316 + foreach (const Template &t, TemplateList::fromGallery(target)) maxSize = max(maxSize, t.bytes());
  317 + }
  318 +
  319 + lines.append(QString("TS,,%1").arg(QString::number(maxSize)));
  320 +
313 // Write SD & KDE 321 // Write SD & KDE
314 points = qMin(qMin(Max_Points, genuines.size()), impostors.size()); 322 points = qMin(qMin(Max_Points, genuines.size()), impostors.size());
315 QList<double> sampledGenuineScores; sampledGenuineScores.reserve(points); 323 QList<double> sampledGenuineScores; sampledGenuineScores.reserve(points);
@@ -337,6 +345,7 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv, const QSt @@ -337,6 +345,7 @@ float Evaluate(const Mat &amp;simmat, const Mat &amp;mask, const QString &amp;csv, const QSt
337 } 345 }
338 346
339 QtUtils::writeFile(csv, lines); 347 QtUtils::writeFile(csv, lines);
  348 + if (maxSize > 0) qDebug("Template Size: %i bytes", (int)maxSize);
340 qDebug("TAR @ FAR = 0.01: %.3f",getTAR(operatingPoints, 0.01)); 349 qDebug("TAR @ FAR = 0.01: %.3f",getTAR(operatingPoints, 0.01));
341 qDebug("TAR @ FAR = 0.001: %.3f",getTAR(operatingPoints, 0.001)); 350 qDebug("TAR @ FAR = 0.001: %.3f",getTAR(operatingPoints, 0.001));
342 qDebug("TAR @ FAR = 0.0001: %.3f",getTAR(operatingPoints, 0.0001)); 351 qDebug("TAR @ FAR = 0.0001: %.3f",getTAR(operatingPoints, 0.0001));
openbr/core/plot.cpp
@@ -157,6 +157,7 @@ struct RPlot @@ -157,6 +157,7 @@ struct RPlot
157 "FT <- data[grep(\"FT\",data$Plot),-c(1)]\n" 157 "FT <- data[grep(\"FT\",data$Plot),-c(1)]\n"
158 "CT <- data[grep(\"CT\",data$Plot),-c(1)]\n" 158 "CT <- data[grep(\"CT\",data$Plot),-c(1)]\n"
159 "BC <- data[grep(\"BC\",data$Plot),-c(1)]\n" 159 "BC <- data[grep(\"BC\",data$Plot),-c(1)]\n"
  160 + "TS <- data[grep(\"TS\",data$Plot),-c(1)]\n"
160 "CMC <- data[grep(\"CMC\",data$Plot),-c(1)]\n" 161 "CMC <- data[grep(\"CMC\",data$Plot),-c(1)]\n"
161 "FAR$Error <- \"FAR\"\n" 162 "FAR$Error <- \"FAR\"\n"
162 "FRR$Error <- \"FRR\"\n" 163 "FRR$Error <- \"FRR\"\n"
@@ -173,6 +174,7 @@ struct RPlot @@ -173,6 +174,7 @@ struct RPlot
173 "FT$Y <- as.numeric(as.character(FT$Y))\n" 174 "FT$Y <- as.numeric(as.character(FT$Y))\n"
174 "CT$Y <- as.numeric(as.character(CT$Y))\n" 175 "CT$Y <- as.numeric(as.character(CT$Y))\n"
175 "BC$Y <- as.numeric(as.character(BC$Y))\n" 176 "BC$Y <- as.numeric(as.character(BC$Y))\n"
  177 + "TS$Y <- as.character(TS$Y)\n"
176 "CMC$Y <- as.numeric(as.character(CMC$Y))\n" 178 "CMC$Y <- as.numeric(as.character(CMC$Y))\n"
177 "\n" 179 "\n"
178 "# Code to format FAR values\n" 180 "# Code to format FAR values\n"
@@ -191,7 +193,13 @@ struct RPlot @@ -191,7 +193,13 @@ struct RPlot
191 "mat <- matrix(CT$Y,nrow=6,ncol=length(algs),byrow=FALSE)\n" 193 "mat <- matrix(CT$Y,nrow=6,ncol=length(algs),byrow=FALSE)\n"
192 "colnames(mat) <- algs \n" 194 "colnames(mat) <- algs \n"
193 "rownames(mat) <- c(\" Rank 1\", \"Rank 5\", \"Rank 10\", \"Rank 20\", \"Rank 50\", \"Rank 100\")\n" 195 "rownames(mat) <- c(\" Rank 1\", \"Rank 5\", \"Rank 10\", \"Rank 20\", \"Rank 50\", \"Rank 100\")\n"
194 - "CMCtable <- as.table(mat)\n").arg(major.header))); 196 + "CMCtable <- as.table(mat)\n"
  197 + "\n"
  198 + "# Code to format Template Size Table\n"
  199 + "mat <- matrix(TS$Y,nrow=1,ncol=length(algs),byrow=FALSE)\n"
  200 + "colnames(mat) <- algs\n"
  201 + "rownames(mat) <- c(\"Template Size (bytes):\")\n"
  202 + "TStable <- as.table(mat)\n").arg(major.header)));
195 203
196 // Open output device 204 // Open output device
197 file.write(qPrintable(QString("\n" 205 file.write(qPrintable(QString("\n"
@@ -222,7 +230,9 @@ struct RPlot @@ -222,7 +230,9 @@ struct RPlot
222 "print(textplot(FTtable))\n" 230 "print(textplot(FTtable))\n"
223 "print(title(\"Table of True Accept Rates at various False Accept Rates\"))\n" 231 "print(title(\"Table of True Accept Rates at various False Accept Rates\"))\n"
224 "print(textplot(CMCtable))\n" 232 "print(textplot(CMCtable))\n"
225 - "print(title(\"Table of retrieval rate at various ranks\"))\n"; 233 + "print(title(\"Table of retrieval rate at various ranks\"))\n"
  234 + "print(textplot(TStable, cex=1.15))\n"
  235 + "print(title(\"Template Size by Algorithm\"))\n";
226 file.write(qPrintable(textplot.arg(PRODUCT_NAME, PRODUCT_VERSION))); 236 file.write(qPrintable(textplot.arg(PRODUCT_NAME, PRODUCT_VERSION)));
227 } 237 }
228 238