diff --git a/openbr/core/eval.cpp b/openbr/core/eval.cpp old mode 100644 new mode 100755 index 3a6b7a4..2e69e65 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -607,11 +607,11 @@ struct DetectionOperatingPoint { float Recall, FalsePositiveRate, Precision; DetectionOperatingPoint() : Recall(-1), FalsePositiveRate(-1), Precision(-1) {} - DetectionOperatingPoint(float TP, float FP, float totalPositives) - : Recall(TP/totalPositives), FalsePositiveRate(FP/totalPositives), Precision(TP/(TP+FP)) {} + DetectionOperatingPoint(float TP, float FP, float totalPositives, float numImages) + : Recall(TP/totalPositives), FalsePositiveRate(FP/numImages), Precision(TP/(TP+FP)) {} }; -static QStringList computeDetectionResults(const QList &detections, int totalTrueDetections, bool discrete) +static QStringList computeDetectionResults(const QList &detections, int totalTrueDetections, int numImages, bool discrete) { QList points; float TP = 0, FP = 0, prevFP = -1; @@ -627,7 +627,7 @@ static QStringList computeDetectionResults(const QList &detec } if ((i == detections.size()-1) || (detection.confidence > detections[i+1].confidence)) { if (FP > prevFP || (i == detections.size()-1)) { - points.append(DetectionOperatingPoint(TP, FP, totalTrueDetections)); + points.append(DetectionOperatingPoint(TP, FP, totalTrueDetections, numImages)); prevFP = FP; } } @@ -745,6 +745,17 @@ static QMap getDetections(const File &predictedGallery, con return allDetections; } +static int getNumberOfImages(const File &truthGallery) +{ + const FileList files = TemplateList::fromGallery(truthGallery).files(); + + QStringList names; + foreach(const File file, files) + if (!names.contains(file.fileName())) + names.append(file.fileName()); + return names.size(); +} + static int associateGroundTruthDetections(QList &resolved, QList &falseNegative, QMap &all, QRectF &offsets) { float dLeftTotal = 0.0, dRightTotal = 0.0, dTopTotal = 0.0, dBottomTotal = 0.0; @@ -864,8 +875,8 @@ float EvalDetection(const QString &predictedGallery, const QString &truthGallery std::sort(resolvedDetections.begin(), resolvedDetections.end()); QStringList lines; lines.append("Plot, X, Y"); - lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, true)); - lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, false)); + lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, getNumberOfImages(truthGallery), true)); + lines.append(computeDetectionResults(resolvedDetections, totalTrueDetections, getNumberOfImages(truthGallery), false)); float averageOverlap; { // Overlap Density diff --git a/openbr/core/plot.cpp b/openbr/core/plot.cpp index f463c48..7868c7d 100644 --- a/openbr/core/plot.cpp +++ b/openbr/core/plot.cpp @@ -350,10 +350,10 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) 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" : QString(", geom=\"%1\"").arg(plotType)) + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + - QString(", xlab=\"Percentage of False Accepts Per Image\", ylab=\"True Accept Rate\") + theme_minimal()") + + QString(", xlab=\"False Accepts Per Image\", ylab=\"True Accept Rate\") + theme_minimal()") + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + - QString(" + scale_x_log10(labels=percent) + scale_y_continuous(labels=percent, limits=c(0,1)) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\") + theme(legend.position=\"bottom\")\n\n").arg(type))); + QString(" + scale_x_log10() + scale_y_continuous(labels=percent, limits=c(0,1)) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\") + theme(legend.position=\"bottom\")\n\n").arg(type))); foreach (const QString &type, QStringList() << "Discrete" << "Continuous") 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" : QString(", geom=\"%1\"").arg(plotType)) + @@ -362,7 +362,7 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + - QString(" + scale_x_continuous(labels=percent, limits=c(0,1)) + scale_y_continuous(labels=percent, limits=c(0,1)) + ggtitle(\"%1\") + theme(legend.position=\"bottom\")\n\n").arg(type))); + QString(" + scale_x_continuous(limits=c(0,1)) + scale_y_continuous(labels=percent, limits=c(0,1)) + ggtitle(\"%1\") + theme(legend.position=\"bottom\")\n\n").arg(type))); p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") + 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))") +