From 8dea5a3e52e8231554df69062d6ec583ffaa3f55 Mon Sep 17 00:00:00 2001 From: Brendan Klare Date: Fri, 18 Oct 2013 16:35:32 -0400 Subject: [PATCH] Sliding window uses "conf" as thresholdable value --- openbr/plugins/slidingwindow.cpp | 13 +++++++------ openbr/plugins/svm.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openbr/plugins/slidingwindow.cpp b/openbr/plugins/slidingwindow.cpp index 105cee5..8bb4c83 100644 --- a/openbr/plugins/slidingwindow.cpp +++ b/openbr/plugins/slidingwindow.cpp @@ -104,7 +104,7 @@ private: continue; negRects.append(negRect); Template neg(tmpl.file, Mat(tmpl, negRect)); - neg.file.set("Label", QString("0")); + neg.file.set("Label", QString("neg")); full += neg; sample++; } @@ -147,19 +147,20 @@ private: for (double y = 0; y + windowHeight < scaleImg.rows; y += stepSize) { for (double x = 0; x + windowWidth < scaleImg.cols; x += stepSize) { -qDebug() << "x=" << x << "\ty=" << y; Rect window(x, y, windowWidth, windowHeight); Template windowMat(src.file, Mat(scaleImg, window)); Template detect; transform->project(windowMat, detect); + float conf = detect.file.get("conf"); + // the result will be in the Label - if (detect.file.get("Label") == "pos") { + if (conf > 0) { dst.file.appendRect(QRectF((float) x * scale, (float) y * scale, (float) windowWidth * scale, (float) windowHeight * scale)); - float confidence = detect.file.get("Dist"); QList confidences = dst.file.getList("Confidences", QList()); - confidences.append(confidence); + confidences.append(conf); dst.file.setList("Confidences", confidences); - if (takeLargestScale) return; + if (takeLargestScale) + return; } } } diff --git a/openbr/plugins/svm.cpp b/openbr/plugins/svm.cpp index a30fe9b..776426e 100644 --- a/openbr/plugins/svm.cpp +++ b/openbr/plugins/svm.cpp @@ -157,7 +157,7 @@ private: dst = src; float prediction = svm.predict(src.m().reshape(1, 1), returnDFVal); if (returnDFVal) { - dst.file.set("Dist", prediction); + dst.file.set("conf", prediction); // positive values ==> first class // negative values ==> second class prediction = prediction > 0 ? 0 : 1; -- libgit2 0.21.4