Commit e8f0b2fbeb4181140068fb09528fb22f5ddf8a06

Authored by bhklein
1 parent 6ef90a88

Sample impostor and genuine matches in the correct direction, compare error rate…

…s at a lower precision to find EERIndex more often.  Update documentation
openbr/core/eval.cpp
... ... @@ -223,7 +223,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv, const QSt
223 223 (truePositives > previousTruePositives)) {
224 224 operatingPoints.append(OperatingPoint(thresh, float(falsePositives)/impostorCount, float(truePositives)/genuineCount));
225 225 if (EERIndex == 0) {
226   - if (floor(float(falsePositives)/impostorCount*1000+0.5)/1000 == floor((1-float(truePositives)/genuineCount)*1000+0.5)/1000) EERIndex = index-1;
  226 + if (floor(float(falsePositives)/impostorCount*100+0.5)/100 == floor((1-float(truePositives)/genuineCount)*100+0.5)/100) EERIndex = index-1;
227 227 }
228 228 previousFalsePositives = falsePositives;
229 229 previousTruePositives = truePositives;
... ... @@ -249,16 +249,16 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv, const QSt
249 249 const FileList queryFiles = TemplateList::fromGallery(query).files();
250 250 unsigned int count = 0;
251 251 for (int i = EERIndex-1; i >= 0; i--) {
252   - if (comparisons[i].genuine) {
253   - lines.append("GM,"+QString::number(comparisons[i].score)+","+targetFiles[comparisons[i].target].get<QString>("Label")+":"
  252 + if (!comparisons[i].genuine) {
  253 + lines.append("IM,"+QString::number(comparisons[i].score)+","+targetFiles[comparisons[i].target].get<QString>("Label")+":"
254 254 +filePath+"/"+targetFiles[comparisons[i].target].name+":"+queryFiles[comparisons[i].query].get<QString>("Label")+":"+filePath+"/"+queryFiles[comparisons[i].query].name);
255 255 if (++count == matches) break;
256 256 }
257 257 }
258 258 count = 0;
259 259 for (int i = EERIndex+1; i < comparisons.size(); i++) {
260   - if (!comparisons[i].genuine) {
261   - lines.append("IM,"+QString::number(comparisons[i].score)+","+targetFiles[comparisons[i].target].get<QString>("Label")+":"
  260 + if (comparisons[i].genuine) {
  261 + lines.append("GM,"+QString::number(comparisons[i].score)+","+targetFiles[comparisons[i].target].get<QString>("Label")+":"
262 262 +filePath+"/"+targetFiles[comparisons[i].target].name+":"+queryFiles[comparisons[i].query].get<QString>("Label")+":"+filePath+"/"+queryFiles[comparisons[i].query].name);
263 263 if (++count == matches) break;
264 264 }
... ...
openbr/core/plot.cpp
... ... @@ -339,7 +339,7 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
339 339 QString("\t\t# Set up the page\n\t\tgrid.newpage()\n\t\tpushViewport(viewport(layout = grid.layout(plotRows, plotCols)))\n\t\tvplayout <- function(x, y)\n\t\t\tviewport(layout.pos.row = x, layout.pos.col = y)\n\n") +
340 340 QString("\t\t# Make each plot, in the correct location\n\t\tfor (i in 1:numPlots) {\n\t\t\tcurRow = ceiling(i/plotCols)\n\t\t\tcurCol = (i-1) %% plotCols + 1\n\t\t\tprint(plots[[i]], vp = vplayout(curRow, curCol))\n\t\t}\n\t}\n\n")));
341 341  
342   - p.file.write(qPrintable(QString("\t# Print top impostor matches\n\tfor (i in 1:nrow(IM)) {\n\t\tscore <- IM[i,1]\n\t\tfiles <- IM[i,2]\n\t\talg <- IM[i,3]\n\t\tfiles <- unlist(strsplit(files, \"[:]\"))\n\n\t\text1 <- unlist(strsplit(files[2], \"[.]\"))[2]\n\t\text2 <- unlist(strsplit(files[4], \"[.]\"))[2]\n\t\t") +
  342 + p.file.write(qPrintable(QString("\t# Print impostor matches above the EER\n\tfor (i in 1:nrow(IM)) {\n\t\tscore <- IM[i,1]\n\t\tfiles <- IM[i,2]\n\t\talg <- IM[i,3]\n\t\tfiles <- unlist(strsplit(files, \"[:]\"))\n\n\t\text1 <- unlist(strsplit(files[2], \"[.]\"))[2]\n\t\text2 <- unlist(strsplit(files[4], \"[.]\"))[2]\n\t\t") +
343 343 QString("if (ext1 == \"jpg\" || ext1 == \"JPEG\" || ext1 == \"jpeg\" || ext1 == \"JPG\") {\n\t\t\timg1 <- readJPEG(files[2])\n\t\t} else if (ext1 == \"PNG\" || ext1 == \"png\") {\n\t\t\timg1 <- readPNG(files[2])\n\t\t} else if (ext1 == \"TIFF\" || ext1 == \"tiff\" || ext1 == \"TIF\" || ext1 == \"tif\") {\n\t\t\timg1 <- readTIFF(files[2])\n\t\t} else {\n\t\t\tnext\n\t\t}\n\t\tif (ext2 == \"jpg\" || ext2 == \"JPEG\" || ext2 == \"jpeg\" || ext2 == \"JPG\") {\n\t\t\timg2 <- readJPEG(files[4])\n\t\t} ") +
344 344 QString("else if (ext2 == \"PNG\" || ext2 == \"png\") {\n\t\t\timg2 <- readPNG(files[4])\n\t\t} else if (ext2 == \"TIFF\" || ext2 == \"tiff\" || ext2 == \"TIF\" || ext2 == \"tif\") {\n\t\t\timg2 <- readTIFF(files[4])\n\t\t} else {\n\t\t\tnext\n\t\t}") +
345 345 QString("\n\t\tname1 <- files[1]\n\t\tname2 <- files[3]\n\n\t\tg1 <- rasterGrob(img1, interpolate=TRUE)\n\t\tg2 <- rasterGrob(img2, interpolate=TRUE)\n\n\t\t") +
... ... @@ -347,7 +347,7 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
347 347 QString("plot2 <- qplot(1:10, 1:10, geom=\"blank\") + annotation_custom(g2, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) + theme(axis.line=element_blank(), axis.text.x=element_blank(), axis.text.y=element_blank(), axis.ticks=element_blank(), panel.background=element_blank()) + labs(title=paste(\"Impostor score =\", score)) + ylab(unlist(strsplit(files[4], \"[/]\"))[length(unlist(strsplit(files[4], \"[/]\")))]) + xlab(name2)\n\n\t\t") +
348 348 QString("multiplot(plot1, plot2, cols=2)\n\t}")));
349 349  
350   - p.file.write(qPrintable(QString("\n\n\t# Print worst genuine matches\n\tfor (i in 1:nrow(GM)) {\n\t\tscore <- GM[i,1]\n\t\tfiles <- GM[i,2]\n\t\talg <- GM[i,3]\n\t\tfiles <- unlist(strsplit(files, \"[:]\"))\n\n\t\text1 <- unlist(strsplit(files[2], \"[.]\"))[2]\n\t\text2 <- unlist(strsplit(files[4], \"[.]\"))[2]\n\t\t") +
  350 + p.file.write(qPrintable(QString("\n\n\t# Print genuine matches below the EER\n\tfor (i in 1:nrow(GM)) {\n\t\tscore <- GM[i,1]\n\t\tfiles <- GM[i,2]\n\t\talg <- GM[i,3]\n\t\tfiles <- unlist(strsplit(files, \"[:]\"))\n\n\t\text1 <- unlist(strsplit(files[2], \"[.]\"))[2]\n\t\text2 <- unlist(strsplit(files[4], \"[.]\"))[2]\n\t\t") +
351 351 QString("if (ext1 == \"jpg\" || ext1 == \"JPEG\" || ext1 == \"jpeg\" || ext1 == \"JPG\") {\n\t\t\timg1 <- readJPEG(files[2])\n\t\t} else if (ext1 == \"PNG\" || ext1 == \"png\") {\n\t\t\timg1 <- readPNG(files[2])\n\t\t} else if (ext1 == \"TIFF\" || ext1 == \"tiff\" || ext1 == \"TIF\" || ext1 == \"tif\") {\n\t\t\timg1 <- readTIFF(files[2])\n\t\t} else {\n\t\t\tnext\n\t\t}\n\t\tif (ext2 == \"jpg\" || ext2 == \"JPEG\" || ext2 == \"jpeg\" || ext2 == \"JPG\") {\n\t\t\timg2 <- readJPEG(files[4])\n\t\t} ") +
352 352 QString("else if (ext2 == \"PNG\" || ext2 == \"png\") {\n\t\t\timg2 <- readPNG(files[4])\n\t\t} else if (ext2 == \"TIFF\" || ext2 == \"tiff\" || ext2 == \"TIF\" || ext2 == \"tif\") {\n\t\t\timg2 <- readTIFF(files[4])\n\t\t} else {\n\t\t\tnext\n\t\t}") +
353 353 QString("\n\t\tname1 <- files[1]\n\t\tname2 <- files[3]\n\n\t\tg1 <- rasterGrob(img1, interpolate=TRUE)\n\t\tg2 <- rasterGrob(img2, interpolate=TRUE)\n\n\t\t") +
... ...
openbr/openbr.h
... ... @@ -154,7 +154,7 @@ BR_EXPORT void br_project(const char *input, const char *output);
154 154 * \param simmat The \ref simmat to use.
155 155 * \param mask The \ref mask to use.
156 156 * \param csv Optional \c .csv file to contain performance metrics.
157   - * \param matches Optional integer number of top impostor matches and bottom genuine matches to output defualts to 0.
  157 + * \param matches Optional integer number of matches to output around the EER, defualts to 0.
158 158 * \return True accept rate at a false accept rate of one in one thousand.
159 159 * \see br_plot
160 160 */
... ... @@ -324,6 +324,7 @@ BR_EXPORT int br_objects(char * buffer, int buffer_length, const char *abstracti
324 324 * The suggested way to plot these experiments on the same graph is to create a folder named <tt>Algorithm_Dataset</tt> that contains the six <tt>.csv</tt> files produced by br_eval <tt>A_Y.csv</tt>, <tt>A_Z.csv</tt>, <tt>B_Y.csv</tt>, <tt>B_Z.csv</tt>, <tt>C_Y.csv</tt>, & <tt>C_Z.csv</tt>.
325 325 * The '<tt>_</tt>' character plays a special role in determining the legend title(s) and value(s).
326 326 * In this case, <tt>A</tt>, <tt>B</tt>, & <tt>C</tt> will be identified as different values of type <tt>Algorithm</tt>, and each will be assigned its own color; <tt>Y</tt> & <tt>Z</tt> will be identified as different values of type Dataset, and each will be assigned its own line style.
  327 + * Matches around the EER will be displayed if the matches parameter is set in \ref br_eval.
327 328 *
328 329 * \param num_files Number of <tt>.csv</tt> files.
329 330 * \param files <tt>.csv</tt> files created using \ref br_eval.
... ... @@ -331,7 +332,7 @@ BR_EXPORT int br_objects(char * buffer, int buffer_length, const char *abstracti
331 332 * \param show Open <i>destination</i>.pdf using the system's default PDF viewer.
332 333 * \return Returns \c true on success. Returns false on a failure to compile the figures due to a missing, out of date, or incomplete \c R installation.
333 334 * \note This function requires a current <a href="http://www.r-project.org/">R</a> installation with the following packages:
334   - * \code install.packages(c("ggplot2", "gplots", "reshape", "scales")) \endcode
  335 + * \code install.packages(c("ggplot2", "gplots", "reshape", "scales", "jpg", "png")) \endcode
335 336 * \see br_eval
336 337 */
337 338 BR_EXPORT bool br_plot(int num_files, const char *files[], const char *destination, bool show = false);
... ...