Commit f282f9c7eea39cf1fdfd3999fd5a1ad31d8b90e4
1 parent
a28a70ba
Added boolean to control cloning window
Showing
1 changed file
with
13 additions
and
2 deletions
openbr/plugins/imgproc/slidingwindow.cpp
| @@ -37,6 +37,10 @@ namespace br | @@ -37,6 +37,10 @@ namespace br | ||
| 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 confidenceThreshold 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 | ||
| 41 | + * \br_property bool group If false, non-maxima supression will not be performed | ||
| 42 | + * \br_property int shrinkingFactor Step value for sliding window | ||
| 43 | + * \br_property bool clone If false, window will not be cloned (i.e. the representation used by the classifier does not need continuous matrix data) | ||
| 40 | */ | 44 | */ |
| 41 | class SlidingWindowTransform : public MetaTransform | 45 | class SlidingWindowTransform : public MetaTransform |
| 42 | { | 46 | { |
| @@ -52,6 +56,8 @@ class SlidingWindowTransform : public MetaTransform | @@ -52,6 +56,8 @@ class SlidingWindowTransform : public MetaTransform | ||
| 52 | 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) |
| 53 | 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) |
| 54 | 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) | ||
| 60 | + | ||
| 55 | BR_PROPERTY(br::Classifier*, classifier, NULL) | 61 | BR_PROPERTY(br::Classifier*, classifier, NULL) |
| 56 | BR_PROPERTY(int, minSize, 20) | 62 | BR_PROPERTY(int, minSize, 20) |
| 57 | BR_PROPERTY(int, maxSize, -1) | 63 | BR_PROPERTY(int, maxSize, -1) |
| @@ -61,6 +67,7 @@ class SlidingWindowTransform : public MetaTransform | @@ -61,6 +67,7 @@ class SlidingWindowTransform : public MetaTransform | ||
| 61 | BR_PROPERTY(int, minNeighbors, 3) | 67 | BR_PROPERTY(int, minNeighbors, 3) |
| 62 | BR_PROPERTY(bool, group, true) | 68 | BR_PROPERTY(bool, group, true) |
| 63 | BR_PROPERTY(int, shrinkingFactor, 1) | 69 | BR_PROPERTY(int, shrinkingFactor, 1) |
| 70 | + BR_PROPERTY(bool, clone, true) | ||
| 64 | 71 | ||
| 65 | void train(const TemplateList &data) | 72 | void train(const TemplateList &data) |
| 66 | { | 73 | { |
| @@ -136,8 +143,12 @@ class SlidingWindowTransform : public MetaTransform | @@ -136,8 +143,12 @@ class SlidingWindowTransform : public MetaTransform | ||
| 136 | const int step = factor > 2.0 ? shrinkingFactor : shrinkingFactor*2; | 143 | const int step = factor > 2.0 ? shrinkingFactor : shrinkingFactor*2; |
| 137 | for (int y = 0; y < scaledImageSize.height-classifierSize.height; y += step) { | 144 | for (int y = 0; y < scaledImageSize.height-classifierSize.height; y += step) { |
| 138 | for (int x = 0; x < scaledImageSize.width-classifierSize.width; x += step) { | 145 | for (int x = 0; x < scaledImageSize.width-classifierSize.width; x += step) { |
| 139 | - for (int i=0; i<rep.size(); i++) | ||
| 140 | - window[i] = rep[i](Rect(Point(x, y), Size(classifierSize.width+dx, classifierSize.height+dy))).clone(); | 146 | + for (int i=0; i<rep.size(); i++) { |
| 147 | + if (clone) | ||
| 148 | + window[i] = rep[i](Rect(Point(x, y), Size(classifierSize.width+dx, classifierSize.height+dy))).clone(); | ||
| 149 | + else | ||
| 150 | + window[i] = rep[i](Rect(Point(x, y), Size(classifierSize.width+dx, classifierSize.height+dy))); | ||
| 151 | + } | ||
| 141 | 152 | ||
| 142 | float confidence = 0; | 153 | float confidence = 0; |
| 143 | int result = classifier->classify(window, false, &confidence); | 154 | int result = classifier->classify(window, false, &confidence); |