Commit 885efbb21cd3cc2a6956e45f76d516fc162eb34f
1 parent
ac20fcb8
Parameter to ignore the border in the sliding window detector
Showing
1 changed file
with
8 additions
and
9 deletions
openbr/plugins/slidingwindow.cpp
| ... | ... | @@ -64,17 +64,16 @@ private: |
| 64 | 64 | aspectRatio = getAspectRatio(data); |
| 65 | 65 | windowHeight = qRound(windowWidth / aspectRatio); |
| 66 | 66 | |
| 67 | - if (ignoreBorder > 0) { | |
| 68 | - foreach (Template t , data) { | |
| 69 | - if (t.file.get<QString>("Label") == "pos") { | |
| 67 | + if (transform->trainable) { | |
| 68 | + TemplateList dataOut = data; | |
| 69 | + if (ignoreBorder > 0) { | |
| 70 | + for (int i = 0; i < dataOut.size(); i++) { | |
| 71 | + Template t = dataOut.at(i); | |
| 70 | 72 | Mat m = t.m(); |
| 71 | - t = Mat(m,Rect(ignoreBorder,ignoreBorder,m.cols - ignoreBorder, m.rows - ignoreBorder)); | |
| 73 | + dataOut.replace(i,Template(t.file, Mat(m,Rect(ignoreBorder,ignoreBorder,m.cols - ignoreBorder * 2, m.rows - ignoreBorder * 2)))); | |
| 72 | 74 | } |
| 73 | 75 | } |
| 74 | - } | |
| 75 | - | |
| 76 | - if (transform->trainable) { | |
| 77 | - transform->train(data); | |
| 76 | + transform->train(dataOut); | |
| 78 | 77 | } |
| 79 | 78 | } |
| 80 | 79 | |
| ... | ... | @@ -113,7 +112,7 @@ protected: |
| 113 | 112 | foreach (const Template &t, src) { |
| 114 | 113 | for (float y = 0; y + windowHeight < t.m().rows; y += windowHeight*stepFraction) { |
| 115 | 114 | for (float x = 0; x + windowWidth < t.m().cols; x += windowWidth*stepFraction) { |
| 116 | - Mat windowMat(t.m(), Rect(x + ignoreBorder, y + ignoreBorder, windowWidth - ignoreBorder, windowHeight - ignoreBorder)); | |
| 115 | + Mat windowMat(t.m(), Rect(x + ignoreBorder, y + ignoreBorder, windowWidth - ignoreBorder * 2, windowHeight - ignoreBorder * 2)); | |
| 117 | 116 | Template detect; |
| 118 | 117 | transform->project(Template(t.file, windowMat), detect); |
| 119 | 118 | ... | ... |