diff --git a/openbr/core/eval.cpp b/openbr/core/eval.cpp index c04dfd6..2dcf4cc 100644 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -384,13 +384,19 @@ static QStringList computeDetectionResults(const QList &detec } const int keep = qMin(points.size(), Max_Points); - if (keep < 2) qFatal("Insufficient points."); + if (keep < 1) qFatal("Insufficient points."); QStringList lines; lines.reserve(keep); - for (int i=0; i 1) + return false; + } + + return true; +} + +//Check all files to see if any single file has only have one ROC point +bool filesHaveSinglePoint(const QStringList &files) { + foreach (const File &file, files) + if (fileHasSinglePoint(file)) + return true; + return false; +} + bool PlotDetection(const QStringList &files, const File &destination, bool show) { qDebug("Plotting %d detection file(s) to %s", files.size(), qPrintable(destination)); @@ -287,8 +315,12 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) "rm(data)\n" "\n"); + QString plotType("line"); + if (filesHaveSinglePoint(files)) + plotType = QString("point"); + foreach (const QString &type, QStringList() << "Discrete" << "Continuous") - 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\"") + + 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=\"False Accepts\", ylab=\"True Accept Rate\") + theme_minimal()") + @@ -297,7 +329,7 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) QString(" + scale_x_log10() + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\")\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" : ", geom=\"line\"") + + 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)) + (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=\"Recall\", ylab=\"Precision\") + theme_minimal()") + diff --git a/openbr/plugins/cascade.cpp b/openbr/plugins/cascade.cpp index e05d9d2..2abb3c6 100644 --- a/openbr/plugins/cascade.cpp +++ b/openbr/plugins/cascade.cpp @@ -99,6 +99,8 @@ class CascadeTransform : public UntrainableMetaTransform Template u(t.file, m); if (rejectLevels.size() > j) u.file.set("Confidence", rejectLevels[j]*levelWeights[j]); + else + u.file.set("Confidence", 1); const QRectF rect = OpenCVUtils::fromRect(rects[j]); u.file.appendRect(rect); u.file.set(model, rect);