Commit e7c3e62ce5faf29e9dbaa6523d2f8245ff670bab

Authored by Scott Klum
2 parents 0ca4f874 7d79754e

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

CHANGELOG.md
1 0.4.0 - ??/??/?? 1 0.4.0 - ??/??/??
2 ================ 2 ================
  3 +* Added -evalDetection and -plotDetection for evaluating and plotting object detection accuracy (#9)
3 4
4 0.3.0 - 5/22/13 5 0.3.0 - 5/22/13
5 =============== 6 ===============
openbr/core/eval.cpp
@@ -380,7 +380,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec @@ -380,7 +380,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec
380 for (int i=0; i<keep; i++) { 380 for (int i=0; i<keep; i++) {
381 const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)]; 381 const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)];
382 lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall))); 382 lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall)));
383 - lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Precision), QString::number(point.Recall))); 383 + lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision)));
384 } 384 }
385 return lines; 385 return lines;
386 } 386 }
openbr/core/plot.cpp
@@ -238,7 +238,6 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show) @@ -238,7 +238,6 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
238 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + 238 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
239 QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n"))); 239 QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n")));
240 240
241 -  
242 p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + 241 p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") +
243 QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + 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 QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + 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,6 +277,39 @@ bool PlotDetection(const QStringList &amp;files, const File &amp;destination, bool show)
278 277
279 RPlot p(files, destination, false); 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 return p.finalize(show); 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,6 +268,18 @@ BR_EXPORT bool br_plot(int num_files, const char *files[], const char *destinati
268 268
269 /*! 269 /*!
270 * \brief Renders detection performance figures for a set of <tt>.csv</tt> files created by \ref br_eval_detection. 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 * \see br_plot 283 * \see br_plot
272 */ 284 */
273 BR_EXPORT bool br_plot_detection(int num_files, const char *files[], const char *destination, bool show = false); 285 BR_EXPORT bool br_plot_detection(int num_files, const char *files[], const char *destination, bool show = false);
openbr/openbr_plugin.cpp
@@ -1166,7 +1166,8 @@ void Transform::project(const TemplateList &amp;src, TemplateList &amp;dst) const @@ -1166,7 +1166,8 @@ void Transform::project(const TemplateList &amp;src, TemplateList &amp;dst) const
1166 dst.append(Template()); 1166 dst.append(Template());
1167 QFutureSynchronizer<void> futures; 1167 QFutureSynchronizer<void> futures;
1168 for (int i=0; i<dst.size(); i++) 1168 for (int i=0; i<dst.size(); i++)
1169 - futures.addFuture(QtConcurrent::run(_project, this, &src[i], &dst[i])); 1169 + if (Globals->parallelism > 1) futures.addFuture(QtConcurrent::run(_project, this, &src[i], &dst[i]));
  1170 + else _project(this, &src[i], &dst[i]);
1170 futures.waitForFinished(); 1171 futures.waitForFinished();
1171 } 1172 }
1172 1173
openbr/plugins/frames.cpp
@@ -18,6 +18,10 @@ class AggregateFrames : public TimeVaryingTransform @@ -18,6 +18,10 @@ class AggregateFrames : public TimeVaryingTransform
18 18
19 TemplateList buffer; 19 TemplateList buffer;
20 20
  21 +public:
  22 + AggregateFrames() : TimeVaryingTransform(false) {}
  23 +
  24 +private:
21 void train(const TemplateList &data) 25 void train(const TemplateList &data)
22 { 26 {
23 (void) data; 27 (void) data;
openbr/plugins/independent.cpp
@@ -99,6 +99,8 @@ class IndependentTransform : public MetaTransform @@ -99,6 +99,8 @@ class IndependentTransform : public MetaTransform
99 return independentTransform; 99 return independentTransform;
100 } 100 }
101 101
  102 + bool timeVarying() const { return transform->timeVarying(); }
  103 +
102 static void _train(Transform *transform, const TemplateList *data) 104 static void _train(Transform *transform, const TemplateList *data)
103 { 105 {
104 transform->train(*data); 106 transform->train(*data);
@@ -143,6 +145,27 @@ class IndependentTransform : public MetaTransform @@ -143,6 +145,27 @@ class IndependentTransform : public MetaTransform
143 dst.append(mats); 145 dst.append(mats);
144 } 146 }
145 147
  148 + void projectUpdate(const Template &src, Template &dst)
  149 + {
  150 + dst.file = src.file;
  151 + QList<Mat> mats;
  152 + for (int i=0; i<src.size(); i++) {
  153 + transforms[i%transforms.size()]->projectUpdate(Template(src.file, src[i]), dst);
  154 + mats.append(dst);
  155 + dst.clear();
  156 + }
  157 + dst.append(mats);
  158 + }
  159 +
  160 + void projectUpdate(const TemplateList &src, TemplateList &dst)
  161 + {
  162 + dst.reserve(src.size());
  163 + foreach (const Template &t, src) {
  164 + dst.append(Template());
  165 + projectUpdate(t, dst.last());
  166 + }
  167 + }
  168 +
146 void store(QDataStream &stream) const 169 void store(QDataStream &stream) const
147 { 170 {
148 const int size = transforms.size(); 171 const int size = transforms.size();
scripts/downloadDatasets.sh
@@ -64,5 +64,6 @@ if [ ! -d ../data/KTH/vid ]; then @@ -64,5 +64,6 @@ if [ ! -d ../data/KTH/vid ]; then
64 rm ${vidclass}.zip 64 rm ${vidclass}.zip
65 done 65 done
66 # this file is corrupted 66 # this file is corrupted
  67 + chmod +w ../data/KTH/vid/boxing/person01_boxing_d4_uncomp.avi
67 rm ../data/KTH/vid/boxing/person01_boxing_d4_uncomp.avi 68 rm ../data/KTH/vid/boxing/person01_boxing_d4_uncomp.avi
68 fi 69 fi