diff --git a/openbr/core/eval.cpp b/openbr/core/eval.cpp index 4d9b4a7..0562309 100644 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -114,8 +114,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) float result = -1; - qDebug() << simmat.rows << simmat.cols; - // Make comparisons QList comparisons; comparisons.reserve(simmat.rows*simmat.cols); int genuineCount = 0, impostorCount = 0, numNaNs = 0; @@ -178,7 +176,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) if ((falsePositives > previousFalsePositives) && (truePositives > previousTruePositives)) { // Restrict the extreme ends of the curve - //if ((truePositives >= 10) && (falsePositives < impostorCount/2)) + if ((truePositives >= 10) && (falsePositives < impostorCount/2)) operatingPoints.append(OperatingPoint(thresh, float(falsePositives)/impostorCount, float(truePositives)/genuineCount)); previousFalsePositives = falsePositives; previousTruePositives = truePositives; diff --git a/openbr/core/plot.cpp b/openbr/core/plot.cpp index ce6efc6..dff8782 100644 --- a/openbr/core/plot.cpp +++ b/openbr/core/plot.cpp @@ -228,7 +228,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) QString(", xlab=\"False Accept Rate\", 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, limits=c(min(DET$X),1)) + scale_y_log10(labels=percent) + annotation_logticks()\n\n"))); + QString(" + scale_x_log10(labels=percent, limits=c(min(DET$X),1)) + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\")\n\n"))); p.file.write(qPrintable(QString("qplot(X, Y, data=DET%1").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + @@ -236,7 +236,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) QString(", xlab=\"False Accept Rate\", ylab=\"False Reject Rate\") + geom_abline(alpha=0.5, colour=\"grey\", linetype=\"dashed\") + 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, limits=c(min(DET$X),1)) + scale_y_continuous(labels=percent)\n\n"))); + QString(" + scale_x_log10(labels=percent, limits=c(min(DET$X),1)) + scale_y_log10(labels=percent) + annotation_logticks()\n\n"))); p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index 27559ef..43a52b2 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -119,7 +119,8 @@ class galGallery : public Gallery { if (t.isEmpty() && t.file.isNull()) return; - stream << t; + + stream << t; } }; diff --git a/openbr/plugins/misc.cpp b/openbr/plugins/misc.cpp index 0516731..9b66378 100644 --- a/openbr/plugins/misc.cpp +++ b/openbr/plugins/misc.cpp @@ -382,35 +382,6 @@ BR_REGISTER(Transform, RegexPropertyTransform) /*! * \ingroup transforms - * \brief Calculate metadata statistics - * \author Scott Klum \cite sklum - */ -class MetadataStatisticsTransform : public UntrainableTransform -{ - Q_OBJECT - Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false) - BR_PROPERTY(QStringList, keys, QStringList()) - - mutable QHash statHash; - - void project(const Template &src, Template &dst) const - { - dst = src; - foreach (const QString &key, keys) { - QString value = src.file.get(key, QString()); - - if (value.isEmpty()) continue; - int count = statHash.value(value,0); - statHash.insert(value,count+1); - } - foreach (const QString &key, statHash.keys()) qDebug() << key << statHash.value(key); - } -}; - -BR_REGISTER(Transform, MetadataStatisticsTransform) - -/*! - * \ingroup transforms * \brief Store the last matrix of the input template as a metadata key with input property name. * \author Charles Otto \cite caotto */ diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index 4eda497..bd850aa 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -348,7 +348,6 @@ class RectFromPointsTransform : public UntrainableTransform if (crop) dst.m() = src.m()(Rect(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height))); else { - qDebug() << QRectF(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height)).size(); dst.file.appendRect(QRectF(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height))); dst.m() = src.m(); } diff --git a/openbr/plugins/stasm4.cpp b/openbr/plugins/stasm4.cpp index cfb4951..0e9f667 100644 --- a/openbr/plugins/stasm4.cpp +++ b/openbr/plugins/stasm4.cpp @@ -58,6 +58,8 @@ class StasmTransform : public UntrainableTransform BR_PROPERTY(bool, stasm3Format, false) Q_PROPERTY(bool clearLandmarks READ get_clearLandmarks WRITE set_clearLandmarks RESET reset_clearLandmarks STORED false) BR_PROPERTY(bool, clearLandmarks, false) + Q_PROPERTY(QStringList pinEyes READ get_pinEyes WRITE set_pinEyes RESET reset_pinEyes STORED false) + BR_PROPERTY(QStringList, pinEyes, QStringList()) Resource stasmCascadeResource; @@ -79,28 +81,41 @@ class StasmTransform : public UntrainableTransform int nLandmarks = stasm_NLANDMARKS; float landmarks[2 * stasm_NLANDMARKS]; - bool pinned = true; + if (!pinEyes.isEmpty()) { + // Two use cases are accounted for: + // 1. Pin eyes without normalization: in this case the string list should contain the KEYS for right then left eyes, respectively. + // 2. Pin eyes with normalization: in this case the string list should contain the COORDINATES of the right then left eyes, respectively. + // Note that for case 2, if Affine_0 and Affine_1 are not present (indicating no normalization has taken place), we default to stasm_search_single. - if (pinned) { - if (src.file.contains("Affine_0")) { - float eyes[2 * stasm_NLANDMARKS]; + bool ok = false; + QPointF rightEye; + QPointF leftEye; - for (int i = 0; i < nLandmarks; i++) { - if (i == 38) { eyes[2*i] = 66.24; eyes[2*i+1] = 126; } - else if (i == 39) { eyes[2*i] = 125.76; eyes[2*i+1] = 126; } - else { eyes[2*i] = 0; eyes[2*i+1] = 0; } + if (src.file.contains("Affine_0") && src.file.contains("Affine_1")) { + rightEye = QtUtils::toPoint(pinEyes.at(0),&ok); + leftEye = QtUtils::toPoint(pinEyes.at(1),&ok); + } + + if (!ok) { + rightEye = QtUtils::toPoint(src.file.get(pinEyes.at(0), QString()),&ok); + leftEye = QtUtils::toPoint(src.file.get(pinEyes.at(1), QString()),&ok); } + float eyes[2 * stasm_NLANDMARKS]; + + if (ok) { + for (int i = 0; i < nLandmarks; i++) { + if (i == 38) /*Stasm Right Eye*/ { eyes[2*i] = rightEye.x(); eyes[2*i+1] = rightEye.y(); } + else if (i == 39) /*Stasm Left Eye*/ { eyes[2*i] = leftEye.x(); eyes[2*i+1] = leftEye.y(); } + else { eyes[2*i] = 0; eyes[2*i+1] = 0; } + } + } else qFatal("Unable to interpret pinned eyes."); + stasm_search_pinned(landmarks, eyes, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, NULL); + // The ASM in Stasm is guaranteed to converge in this case foundface = 1; - } else { - qDebug() << "Single search..."; - stasm_search_single(&foundface, landmarks, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); - } - } else { - stasm_search_single(&foundface, landmarks, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); - } + } stasm_search_single(&foundface, landmarks, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); if (stasm3Format) { nLandmarks = 76; @@ -109,6 +124,7 @@ class StasmTransform : public UntrainableTransform stasmCascadeResource.release(stasmCascade); + // For convenience, if these are the only points/rects we want to deal with as the algorithm progresses if (clearLandmarks) { dst.file.clearPoints(); dst.file.clearRects(); @@ -124,8 +140,6 @@ class StasmTransform : public UntrainableTransform else if (i == 39) dst.file.set("StasmLeftEye", point); } } - - dst.m() = src.m(); } };