Commit 560e477d6bd6f2d6139612e19c3f4fe0095e8b8b

Authored by Brendan Klare
1 parent 52dc5736

Option to ignore border on sliding window

openbr/plugins/slidingwindow.cpp
... ... @@ -46,11 +46,13 @@ class SlidingWindowTransform : public MetaTransform
46 46 Q_PROPERTY(bool takeFirst READ get_takeFirst WRITE set_takeFirst RESET reset_takeFirst STORED false)
47 47 Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false)
48 48 Q_PROPERTY(float stepFraction READ get_stepFraction WRITE set_stepFraction RESET reset_stepFraction STORED false)
  49 + Q_PROPERTY(int ignoreBorder READ get_ignoreBorder WRITE set_ignoreBorder RESET reset_ignoreBorder STORED false)
49 50 BR_PROPERTY(br::Transform *, transform, NULL)
50 51 BR_PROPERTY(int, windowWidth, 24)
51 52 BR_PROPERTY(bool, takeFirst, false)
52 53 BR_PROPERTY(float, threshold, 0)
53 54 BR_PROPERTY(float, stepFraction, 0.25)
  55 + BR_PROPERTY(int, ignoreBorder, 0)
54 56  
55 57 private:
56 58 int windowHeight;
... ... @@ -61,6 +63,16 @@ private:
61 63 if (aspectRatio == -1)
62 64 aspectRatio = getAspectRatio(data);
63 65 windowHeight = qRound(windowWidth / aspectRatio);
  66 +
  67 + if (ignoreBorder > 0) {
  68 + foreach (Template t , data) {
  69 + if (t.file.get<QString>("Label") == "pos") {
  70 + Mat m = t.m();
  71 + t = Mat(m,Rect(ignoreBorder,ignoreBorder,m.cols - ignoreBorder, m.rows - ignoreBorder));
  72 + }
  73 + }
  74 + }
  75 +
64 76 if (transform->trainable) {
65 77 transform->train(data);
66 78 }
... ... @@ -101,7 +113,7 @@ protected:
101 113 foreach (const Template &t, src) {
102 114 for (float y = 0; y + windowHeight < t.m().rows; y += windowHeight*stepFraction) {
103 115 for (float x = 0; x + windowWidth < t.m().cols; x += windowWidth*stepFraction) {
104   - Mat windowMat(t.m(), Rect(x, y, windowWidth, windowHeight));
  116 + Mat windowMat(t.m(), Rect(x + ignoreBorder, y + ignoreBorder, windowWidth - ignoreBorder, windowHeight - ignoreBorder));
105 117 Template detect;
106 118 transform->project(Template(t.file, windowMat), detect);
107 119  
... ...