Commit 7d79754e29b5232fcbfc20c4a009a850ecd6ab4a

Authored by Austin Van Blanton
2 parents da198c6a dd26bb60

Merge branch 'master' of https://github.com/biometrics/openbr

CHANGELOG.md
1 1 0.4.0 - ??/??/??
2 2 ================
  3 +* Added -evalDetection and -plotDetection for evaluating and plotting object detection accuracy (#9)
3 4  
4 5 0.3.0 - 5/22/13
5 6 ===============
... ...
openbr/core/eval.cpp
... ... @@ -377,7 +377,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec
377 377 for (int i=0; i<keep; i++) {
378 378 const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)];
379 379 lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall)));
380   - lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Precision), QString::number(point.Recall)));
  380 + lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision)));
381 381 }
382 382 return lines;
383 383 }
... ...
openbr/core/plot.cpp
... ... @@ -238,7 +238,6 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
238 238 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
239 239 QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n")));
240 240  
241   -
242 241 p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") +
243 242 QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) +
244 243 QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) +
... ... @@ -278,6 +277,39 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show)
278 277  
279 278 RPlot p(files, destination, false);
280 279  
  280 + p.file.write("# Split data into individual plots\n"
  281 + "plot_index = which(names(data)==\"Plot\")\n"
  282 + "DiscreteROC <- data[grep(\"DiscreteROC\",data$Plot),-c(1)]\n"
  283 + "ContinuousROC <- data[grep(\"ContinuousROC\",data$Plot),-c(1)]\n"
  284 + "DiscretePR <- data[grep(\"DiscretePR\",data$Plot),-c(1)]\n"
  285 + "ContinuousPR <- data[grep(\"ContinuousPR\",data$Plot),-c(1)]\n"
  286 + "Overlap <- data[grep(\"Overlap\",data$Plot),-c(1)]\n"
  287 + "rm(data)\n"
  288 + "\n");
  289 +
  290 + foreach (const QString &type, QStringList() << "Discrete" << "Continuous")
  291 + p.file.write(qPrintable(QString("qplot(X, Y, data=%1ROC%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") +
  292 + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) +
  293 + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) +
  294 + QString(", xlab=\"False Accepts\", ylab=\"True Accept Rate\") + theme_minimal()") +
  295 + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
  296 + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
  297 + QString(" + scale_x_log10() + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\")\n\n").arg(type)));
  298 +
  299 + foreach (const QString &type, QStringList() << "Discrete" << "Continuous")
  300 + p.file.write(qPrintable(QString("qplot(X, Y, data=%1PR%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") +
  301 + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) +
  302 + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) +
  303 + QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") +
  304 + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
  305 + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
  306 + QString(" + scale_x_continuous(labels=percent) + scale_y_continuous(labels=percent) + ggtitle(\"%1\")\n\n").arg(type)));
  307 +
  308 + p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") +
  309 + QString(" + theme_minimal() + scale_x_continuous(minor_breaks=NULL) + scale_y_continuous(minor_breaks=NULL) + theme(axis.text.y=element_blank(), axis.ticks=element_blank(), axis.text.x=element_text(angle=-90, hjust=0))") +
  310 + (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg(p.minor.header, p.major.header) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) +
  311 + QString(" + theme(aspect.ratio=1)\n\n")));
  312 +
281 313 return p.finalize(show);
282 314 }
283 315  
... ...
openbr/openbr.h
... ... @@ -268,6 +268,18 @@ BR_EXPORT bool br_plot(int num_files, const char *files[], const char *destinati
268 268  
269 269 /*!
270 270 * \brief Renders detection performance figures for a set of <tt>.csv</tt> files created by \ref br_eval_detection.
  271 + *
  272 + * In order of their output, the figures are:
  273 + * -# Discrete Receiver Operating Characteristic (DiscreteROC)
  274 + * -# Continuous Receiver Operating Characteristic (ContinuousROC)
  275 + * -# Discrete Precision Recall (DiscretePR)
  276 + * -# Continuous Precision Recall (ContinuousPR)
  277 + * -# Bounding Box Overlap Histogram (Overlap)
  278 + *
  279 + * Detection accuracy is measured with <i>overlap fraction = bounding box intersection / union</i>.
  280 + * When computing <i>discrete</i> curves, an overlap >= 0.5 is considered a true positive, otherwise it is considered a false negative.
  281 + * When computing <i>continuous</i> curves, true positives and false negatives are measured fractionally as <i>overlap</i> and <i>1-overlap</i> respectively.
  282 + *
271 283 * \see br_plot
272 284 */
273 285 BR_EXPORT bool br_plot_detection(int num_files, const char *files[], const char *destination, bool show = false);
... ...