Commit 8dea5a3e52e8231554df69062d6ec583ffaa3f55
1 parent
12468946
Sliding window uses "conf" as thresholdable value
Showing
2 changed files
with
8 additions
and
7 deletions
openbr/plugins/slidingwindow.cpp
| @@ -104,7 +104,7 @@ private: | @@ -104,7 +104,7 @@ private: | ||
| 104 | continue; | 104 | continue; |
| 105 | negRects.append(negRect); | 105 | negRects.append(negRect); |
| 106 | Template neg(tmpl.file, Mat(tmpl, negRect)); | 106 | Template neg(tmpl.file, Mat(tmpl, negRect)); |
| 107 | - neg.file.set("Label", QString("0")); | 107 | + neg.file.set("Label", QString("neg")); |
| 108 | full += neg; | 108 | full += neg; |
| 109 | sample++; | 109 | sample++; |
| 110 | } | 110 | } |
| @@ -147,19 +147,20 @@ private: | @@ -147,19 +147,20 @@ private: | ||
| 147 | 147 | ||
| 148 | for (double y = 0; y + windowHeight < scaleImg.rows; y += stepSize) { | 148 | for (double y = 0; y + windowHeight < scaleImg.rows; y += stepSize) { |
| 149 | for (double x = 0; x + windowWidth < scaleImg.cols; x += stepSize) { | 149 | for (double x = 0; x + windowWidth < scaleImg.cols; x += stepSize) { |
| 150 | -qDebug() << "x=" << x << "\ty=" << y; | ||
| 151 | Rect window(x, y, windowWidth, windowHeight); | 150 | Rect window(x, y, windowWidth, windowHeight); |
| 152 | Template windowMat(src.file, Mat(scaleImg, window)); | 151 | Template windowMat(src.file, Mat(scaleImg, window)); |
| 153 | Template detect; | 152 | Template detect; |
| 154 | transform->project(windowMat, detect); | 153 | transform->project(windowMat, detect); |
| 154 | + float conf = detect.file.get<float>("conf"); | ||
| 155 | + | ||
| 155 | // the result will be in the Label | 156 | // the result will be in the Label |
| 156 | - if (detect.file.get<QString>("Label") == "pos") { | 157 | + if (conf > 0) { |
| 157 | dst.file.appendRect(QRectF((float) x * scale, (float) y * scale, (float) windowWidth * scale, (float) windowHeight * scale)); | 158 | dst.file.appendRect(QRectF((float) x * scale, (float) y * scale, (float) windowWidth * scale, (float) windowHeight * scale)); |
| 158 | - float confidence = detect.file.get<float>("Dist"); | ||
| 159 | QList<float> confidences = dst.file.getList<float>("Confidences", QList<float>()); | 159 | QList<float> confidences = dst.file.getList<float>("Confidences", QList<float>()); |
| 160 | - confidences.append(confidence); | 160 | + confidences.append(conf); |
| 161 | dst.file.setList<float>("Confidences", confidences); | 161 | dst.file.setList<float>("Confidences", confidences); |
| 162 | - if (takeLargestScale) return; | 162 | + if (takeLargestScale) |
| 163 | + return; | ||
| 163 | } | 164 | } |
| 164 | } | 165 | } |
| 165 | } | 166 | } |
openbr/plugins/svm.cpp
| @@ -157,7 +157,7 @@ private: | @@ -157,7 +157,7 @@ private: | ||
| 157 | dst = src; | 157 | dst = src; |
| 158 | float prediction = svm.predict(src.m().reshape(1, 1), returnDFVal); | 158 | float prediction = svm.predict(src.m().reshape(1, 1), returnDFVal); |
| 159 | if (returnDFVal) { | 159 | if (returnDFVal) { |
| 160 | - dst.file.set("Dist", prediction); | 160 | + dst.file.set("conf", prediction); |
| 161 | // positive values ==> first class | 161 | // positive values ==> first class |
| 162 | // negative values ==> second class | 162 | // negative values ==> second class |
| 163 | prediction = prediction > 0 ? 0 : 1; | 163 | prediction = prediction > 0 ? 0 : 1; |