Commit a82be1086ff5a22f48d73bd5000b14ce1106b243

Authored by Brendan Klare
2 parents 8894ce2c d13d9b07

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

openbr/core/bee.cpp
... ... @@ -111,25 +111,27 @@ void BEE::writeSigset(const QString &sigset, const br::FileList &files, bool ign
111 111 lines.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
112 112 lines.append("<biometric-signature-set>");
113 113 foreach (const File &file, files) {
114   - QStringList metadata;
115   - if (!ignoreMetadata) {
116   - foreach (const QString &key, file.localKeys()) {
117   - if ((key == "Index") || (key == "Label") || (key == "Points") || (key == "Rects")) continue;
118   - metadata.append(key+"=\""+QtUtils::toString(file.value(key))+"\"");
119   - }
120   - QStringList landmarks;
121   - if (!file.points().isEmpty()) {
122   - foreach (const QPointF &point, file.points()) landmarks.append(QtUtils::toString(point));
123   - metadata.append("Points=\"["+landmarks.join(",")+"]\""); landmarks.clear();
124   - }
125   - if (!file.rects().isEmpty()) {
126   - foreach (const QRectF &rect, file.rects()) landmarks.append(QtUtils::toString(rect));
127   - metadata.append("Rects=\"["+landmarks.join(",")+"]\"");
  114 + if (!file.isNull()) {
  115 + QStringList metadata;
  116 + if (!ignoreMetadata) {
  117 + foreach (const QString &key, file.localKeys()) {
  118 + if ((key == "Index") || (key == "Label") || (key == "Points") || (key == "Rects")) continue;
  119 + metadata.append(key+"=\""+QtUtils::toString(file.value(key))+"\"");
  120 + }
  121 + QStringList landmarks;
  122 + if (!file.points().isEmpty()) {
  123 + foreach (const QPointF &point, file.points()) landmarks.append(QtUtils::toString(point));
  124 + metadata.append("Points=\"["+landmarks.join(",")+"]\""); landmarks.clear();
  125 + }
  126 + if (!file.rects().isEmpty()) {
  127 + foreach (const QRectF &rect, file.rects()) landmarks.append(QtUtils::toString(rect));
  128 + metadata.append("Rects=\"["+landmarks.join(",")+"]\"");
  129 + }
128 130 }
  131 + lines.append("\t<biometric-signature name=\"" + file.get<QString>("Label",file.baseName()) +"\">");
  132 + lines.append("\t\t<presentation file-name=\"" + file.name + "\" " + metadata.join(" ") + "/>");
  133 + lines.append("\t</biometric-signature>");
129 134 }
130   - lines.append("\t<biometric-signature name=\"" + file.get<QString>("Label",file.baseName()) +"\">");
131   - lines.append("\t\t<presentation file-name=\"" + file.name + "\" " + metadata.join(" ") + "/>");
132   - lines.append("\t</biometric-signature>");
133 135 }
134 136 lines.append("</biometric-signature-set>");
135 137 QtUtils::writeFile(sigset, lines);
... ...
openbr/plugins/eigen3.cpp
... ... @@ -15,6 +15,7 @@
15 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16  
17 17 #include <Eigen/Dense>
  18 +
18 19 #include "openbr_internal.h"
19 20  
20 21 #include "openbr/core/common.h"
... ... @@ -25,6 +26,24 @@ namespace br
25 26 {
26 27  
27 28 /*!
  29 + * \ingroup initializers
  30 + * \brief Initialize Eigen
  31 + * http://eigen.tuxfamily.org/dox/TopicMultiThreading.html
  32 + * \author Scott Klum \cite sklum
  33 + */
  34 +class EigenInitializer : public Initializer
  35 +{
  36 + Q_OBJECT
  37 +
  38 + void initialize() const
  39 + {
  40 + Eigen::initParallel();
  41 + }
  42 +};
  43 +
  44 +BR_REGISTER(Initializer, EigenInitializer)
  45 +
  46 +/*!
28 47 * \ingroup transforms
29 48 * \brief Projects input into learned Principal Component Analysis subspace.
30 49 * \author Brendan Klare \cite bklare
... ... @@ -508,6 +527,7 @@ class LDATransform : public Transform
508 527  
509 528 void store(QDataStream &stream) const
510 529 {
  530 + stream << pcaKeep;
511 531 stream << directLDA;
512 532 stream << directDrop;
513 533 stream << dimsOut;
... ... @@ -519,6 +539,7 @@ class LDATransform : public Transform
519 539  
520 540 void load(QDataStream &stream)
521 541 {
  542 + stream >> pcaKeep;
522 543 stream >> directLDA;
523 544 stream >> directDrop;
524 545 stream >> dimsOut;
... ...
openbr/plugins/gui.cpp
... ... @@ -413,13 +413,13 @@ private:
413 413  
414 414 };
415 415  
416   -class DisplayGUI : public QMainWindow
  416 +class GUIWindow : public QMainWindow
417 417 {
418 418 Q_OBJECT
419 419  
420 420 public:
421 421  
422   - DisplayGUI(QWidget * parent = NULL) : QMainWindow(parent)
  422 + GUIWindow(QWidget * parent = NULL) : QMainWindow(parent)
423 423 {
424 424 centralWidget = new QWidget();
425 425 layout = new QHBoxLayout();
... ... @@ -592,8 +592,10 @@ public:
592 592 template<typename WindowType>
593 593 void initActual()
594 594 {
595   - if (!Globals->useGui)
  595 + if (!Globals->useGui) {
  596 + qWarning("GUI transform %s created without enabling GUI support.\nRun \"br -gui ...\" to enable GUI support from the command line, or set\nGlobals->useGui to true.", this->metaObject()->className());
596 597 return;
  598 + }
597 599  
598 600 if (displayBuffer)
599 601 delete displayBuffer;
... ... @@ -795,7 +797,7 @@ class ElicitTransform : public ShowTransform
795 797  
796 798 Q_OBJECT
797 799  
798   - DisplayGUI *gui;
  800 + GUIWindow *gui;
799 801  
800 802 public:
801 803 ElicitTransform() : ShowTransform()
... ... @@ -835,14 +837,16 @@ public:
835 837  
836 838 void init()
837 839 {
838   - initActual<DisplayGUI>();
  840 + initActual<GUIWindow>();
839 841 }
840 842  
841 843 template<typename GUIType>
842 844 void initActual()
843 845 {
844   - if (!Globals->useGui)
  846 + if (!Globals->useGui) {
  847 + qWarning("GUI transform %s created without enabling GUI support.\nRun \"br -gui ...\" to enable GUI support from the command line, or set\nGlobals->useGui to true.", this->metaObject()->className());
845 848 return;
  849 + }
846 850  
847 851 TimeVaryingTransform::init();
848 852  
... ...
openbr/plugins/independent.cpp
... ... @@ -9,13 +9,14 @@ 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 QStringList &gallery)
  12 +static TemplateList Downsample(const TemplateList &templates, int classes, int instances, float fraction, const QString & inputVariable, const QStringList &gallery, const QStringList &subjects)
13 13 {
14 14 // Return early when no downsampling is required
15 15 if ((classes == std::numeric_limits<int>::max()) &&
16 16 (instances == std::numeric_limits<int>::max()) &&
17 17 (fraction >= 1) &&
18   - (gallery.isEmpty()))
  18 + (gallery.isEmpty()) &&
  19 + (subjects.isEmpty()))
19 20 return templates;
20 21  
21 22 const bool atLeast = instances < 0;
... ... @@ -66,6 +67,11 @@ static TemplateList Downsample(const TemplateList &amp;templates, int classes, int i
66 67 if (!gallery.contains(downsample[i].file.get<QString>("Gallery")))
67 68 downsample.removeAt(i);
68 69  
  70 + if (!subjects.isEmpty())
  71 + for (int i=downsample.size()-1; i>=0; i--)
  72 + if (subjects.contains(downsample[i].file.get<QString>(inputVariable)))
  73 + downsample.removeAt(i);
  74 +
69 75 return downsample;
70 76 }
71 77  
... ... @@ -78,12 +84,15 @@ class DownsampleTrainingTransform : public Transform
78 84 Q_PROPERTY(float fraction READ get_fraction WRITE set_fraction RESET reset_fraction STORED false)
79 85 Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false)
80 86 Q_PROPERTY(QStringList gallery READ get_gallery WRITE set_gallery RESET reset_gallery STORED false)
  87 + Q_PROPERTY(QStringList subjects READ get_subjects WRITE set_subjects RESET reset_subjects STORED false)
81 88 BR_PROPERTY(br::Transform*, transform, NULL)
82 89 BR_PROPERTY(int, classes, std::numeric_limits<int>::max())
83 90 BR_PROPERTY(int, instances, std::numeric_limits<int>::max())
84 91 BR_PROPERTY(float, fraction, 1)
85 92 BR_PROPERTY(QString, inputVariable, "Label")
86 93 BR_PROPERTY(QStringList, gallery, QStringList())
  94 + BR_PROPERTY(QStringList, subjects, QStringList())
  95 +
87 96  
88 97 void project(const Template & src, Template & dst) const
89 98 {
... ... @@ -96,7 +105,7 @@ class DownsampleTrainingTransform : public Transform
96 105 if (!transform || !transform->trainable)
97 106 return;
98 107  
99   - TemplateList downsampled = Downsample(data, classes, instances, fraction, inputVariable, gallery);
  108 + TemplateList downsampled = Downsample(data, classes, instances, fraction, inputVariable, gallery, subjects);
100 109  
101 110 transform->train(downsampled);
102 111 }
... ...