Commit 98461b648ff2a5f2a4295518513d2bd3be1e1cea

Authored by Josh Klontz
2 parents d0d17f39 61a43e72

erge branch 'master' of https://github.com/biometrics/openbr

openbr/plugins/independent.cpp
... ... @@ -9,7 +9,7 @@ using namespace cv;
9 9 namespace br
10 10 {
11 11  
12   -static TemplateList Downsample(const TemplateList &templates, int classes, int instances, float fraction, const QString & inputVariable, const QString &gallery)
  12 +static TemplateList Downsample(const TemplateList &templates, int classes, int instances, float fraction, const QString & inputVariable, const QStringList &gallery)
13 13 {
14 14 // Return early when no downsampling is required
15 15 if ((classes == std::numeric_limits<int>::max()) &&
... ... @@ -62,9 +62,9 @@ static TemplateList Downsample(const TemplateList &amp;templates, int classes, int i
62 62 }
63 63  
64 64 if (!gallery.isEmpty())
65   - foreach(const Template &t, templates)
66   - if (t.file.get<QString>("Gallery") == gallery)
67   - downsample.append(t);
  65 + for (int i=downsample.size()-1; i>=0; i--)
  66 + if (!gallery.contains(downsample[i].file.get<QString>("Gallery")))
  67 + downsample.removeAt(i);
68 68  
69 69 return downsample;
70 70 }
... ... @@ -77,13 +77,13 @@ class DownsampleTrainingTransform : public Transform
77 77 Q_PROPERTY(int instances READ get_instances WRITE set_instances RESET reset_instances STORED false)
78 78 Q_PROPERTY(float fraction READ get_fraction WRITE set_fraction RESET reset_fraction STORED false)
79 79 Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false)
80   - Q_PROPERTY(QString gallery READ get_gallery WRITE set_gallery RESET reset_gallery STORED false)
  80 + Q_PROPERTY(QStringList gallery READ get_gallery WRITE set_gallery RESET reset_gallery STORED false)
81 81 BR_PROPERTY(br::Transform*, transform, NULL)
82 82 BR_PROPERTY(int, classes, std::numeric_limits<int>::max())
83 83 BR_PROPERTY(int, instances, std::numeric_limits<int>::max())
84 84 BR_PROPERTY(float, fraction, 1)
85 85 BR_PROPERTY(QString, inputVariable, "Label")
86   - BR_PROPERTY(QString, gallery, QString())
  86 + BR_PROPERTY(QStringList, gallery, QStringList())
87 87  
88 88 void project(const Template & src, Template & dst) const
89 89 {
... ... @@ -97,6 +97,7 @@ class DownsampleTrainingTransform : public Transform
97 97 return;
98 98  
99 99 TemplateList downsampled = Downsample(data, classes, instances, fraction, inputVariable, gallery);
  100 +
100 101 transform->train(downsampled);
101 102 }
102 103 };
... ...