Commit 26733720ecf1393ae438ddfc4ffa6a29ab216dae

Authored by Scott Klum
1 parent 35001d4c

Some changes to slidingwindow functionality

openbr/plugins/imgproc/slidingwindow.cpp
@@ -35,7 +35,7 @@ namespace br @@ -35,7 +35,7 @@ namespace br
35 * \br_property int minSize The smallest sized object to detect in pixels 35 * \br_property int minSize The smallest sized object to detect in pixels
36 * \br_property int maxSize The largest sized object to detect in pixels. A negative value will set maxSize == image size 36 * \br_property int maxSize The largest sized object to detect in pixels. A negative value will set maxSize == image size
37 * \br_property float scaleFactor The factor to scale the image by during each resize. 37 * \br_property float scaleFactor The factor to scale the image by during each resize.
38 - * \br_property float confidenceThreshold A threshold for positive detections. Positive detections returned by the classifier that have confidences below this threshold are considered negative detections. 38 + * \br_property float minGroupingConfidence A threshold for positive detections. Positive detections returned by the classifier that have confidences below this threshold are considered negative detections.
39 * \br_property float eps Parameter for non-maximum supression 39 * \br_property float eps Parameter for non-maximum supression
40 * \br_property int minNeighbors Parameter for non-maximum supression 40 * \br_property int minNeighbors Parameter for non-maximum supression
41 * \br_property bool group If false, non-maxima supression will not be performed 41 * \br_property bool group If false, non-maxima supression will not be performed
@@ -51,23 +51,28 @@ class SlidingWindowTransform : public MetaTransform @@ -51,23 +51,28 @@ class SlidingWindowTransform : public MetaTransform
51 Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false) 51 Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false)
52 Q_PROPERTY(int maxSize READ get_maxSize WRITE set_maxSize RESET reset_maxSize STORED false) 52 Q_PROPERTY(int maxSize READ get_maxSize WRITE set_maxSize RESET reset_maxSize STORED false)
53 Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false) 53 Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false)
54 - Q_PROPERTY(float confidenceThreshold READ get_confidenceThreshold WRITE set_confidenceThreshold RESET reset_confidenceThreshold STORED false) 54 + Q_PROPERTY(float minGroupingConfidence READ get_minGroupingConfidence WRITE set_minGroupingConfidence RESET reset_minGroupingConfidence STORED false)
55 Q_PROPERTY(float eps READ get_eps WRITE set_eps RESET reset_eps STORED false) 55 Q_PROPERTY(float eps READ get_eps WRITE set_eps RESET reset_eps STORED false)
56 Q_PROPERTY(float minNeighbors READ get_minNeighbors WRITE set_minNeighbors RESET reset_minNeighbors STORED false) 56 Q_PROPERTY(float minNeighbors READ get_minNeighbors WRITE set_minNeighbors RESET reset_minNeighbors STORED false)
57 Q_PROPERTY(bool group READ get_group WRITE set_group RESET reset_group STORED false) 57 Q_PROPERTY(bool group READ get_group WRITE set_group RESET reset_group STORED false)
58 Q_PROPERTY(int shrinkingFactor READ get_shrinkingFactor WRITE set_shrinkingFactor RESET reset_shrinkingFactor STORED false) 58 Q_PROPERTY(int shrinkingFactor READ get_shrinkingFactor WRITE set_shrinkingFactor RESET reset_shrinkingFactor STORED false)
59 Q_PROPERTY(bool clone READ get_clone WRITE set_clone RESET reset_clone STORED false) 59 Q_PROPERTY(bool clone READ get_clone WRITE set_clone RESET reset_clone STORED false)
60 - 60 + Q_PROPERTY(float minConfidence READ get_minConfidence WRITE set_minConfidence RESET reset_minConfidence STORED false)
  61 + Q_PROPERTY(bool ROCMode READ get_ROCMode WRITE set_ROCMode RESET reset_ROCMode STORED false)
  62 + Q_PROPERTY(QString outputVariable READ get_outputVariable WRITE set_outputVariable RESET reset_outputVariable STORED false)
61 BR_PROPERTY(br::Classifier*, classifier, NULL) 63 BR_PROPERTY(br::Classifier*, classifier, NULL)
62 BR_PROPERTY(int, minSize, 20) 64 BR_PROPERTY(int, minSize, 20)
63 BR_PROPERTY(int, maxSize, -1) 65 BR_PROPERTY(int, maxSize, -1)
64 BR_PROPERTY(float, scaleFactor, 1.2) 66 BR_PROPERTY(float, scaleFactor, 1.2)
65 - BR_PROPERTY(float, confidenceThreshold, 10) 67 + BR_PROPERTY(float, minGroupingConfidence, -std::numeric_limits<float>::max())
66 BR_PROPERTY(float, eps, 0.2) 68 BR_PROPERTY(float, eps, 0.2)
67 BR_PROPERTY(int, minNeighbors, 3) 69 BR_PROPERTY(int, minNeighbors, 3)
68 BR_PROPERTY(bool, group, true) 70 BR_PROPERTY(bool, group, true)
69 BR_PROPERTY(int, shrinkingFactor, 1) 71 BR_PROPERTY(int, shrinkingFactor, 1)
70 BR_PROPERTY(bool, clone, true) 72 BR_PROPERTY(bool, clone, true)
  73 + BR_PROPERTY(float, minConfidence, 0)
  74 + BR_PROPERTY(bool, ROCMode, false)
  75 + BR_PROPERTY(QString, outputVariable, "FrontalFace")
71 76
72 void train(const TemplateList &data) 77 void train(const TemplateList &data)
73 { 78 {
@@ -163,20 +168,23 @@ class SlidingWindowTransform : public MetaTransform @@ -163,20 +168,23 @@ class SlidingWindowTransform : public MetaTransform
163 } 168 }
164 169
165 if (group) 170 if (group)
166 - OpenCVUtils::group(rects, confidences, confidenceThreshold, minNeighbors, eps); 171 + OpenCVUtils::group(rects, confidences, minGroupingConfidence, minNeighbors, eps);
167 172
168 if (!enrollAll && rects.empty()) { 173 if (!enrollAll && rects.empty()) {
169 rects.append(Rect(0, 0, imageSize.width, imageSize.height)); 174 rects.append(Rect(0, 0, imageSize.width, imageSize.height));
170 confidences.append(-std::numeric_limits<float>::max()); 175 confidences.append(-std::numeric_limits<float>::max());
171 } 176 }
172 177
  178 + const float minConfidence = t.file.get<float>("MinConfidence", this->minConfidence);
173 for (int j=0; j<rects.size(); j++) { 179 for (int j=0; j<rects.size(); j++) {
174 - Template u = t;  
175 - u.file.set("Confidence", confidences[j]);  
176 - const QRectF rect = OpenCVUtils::fromRect(rects[j]);  
177 - u.file.appendRect(rect);  
178 - u.file.set("Face", rect);  
179 - dst.append(u); 180 + if (ROCMode || confidences[j] >= minConfidence) {
  181 + Template u = t;
  182 + u.file.set("Confidence", confidences[j]);
  183 + const QRectF rect = OpenCVUtils::fromRect(rects[j]);
  184 + u.file.appendRect(rect);
  185 + u.file.set(outputVariable, rect);
  186 + dst.append(u);
  187 + }
180 } 188 }
181 } 189 }
182 } 190 }