Commit 854948b3d64261984ef284dbd5fc789501f0aa8b

Authored by Mark Burge
2 parents 8c3d1bf1 edabd67a

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

openbr/core/eigenutils.cpp
@@ -16,4 +16,32 @@ void writeEigen(MatrixXf X, QString filename) { @@ -16,4 +16,32 @@ void writeEigen(MatrixXf X, QString filename) {
16 format->write(br::Template(m)); 16 format->write(br::Template(m));
17 } 17 }
18 18
  19 +void writeEigen(MatrixXd X, QString filename) {
  20 + Mat m(X.rows(),X.cols(),CV_32FC1);
  21 + for (int i = 0; i < X.rows(); i++) {
  22 + for (int j = 0; j < X.cols(); j++) {
  23 + m.at<float>(i,j) = (float)X(i,j);
  24 + }
  25 + }
  26 + QScopedPointer<br::Format> format(br::Factory<br::Format>::make(filename));
  27 + format->write(br::Template(m));
  28 +}
19 29
  30 +void writeEigen(VectorXd X, QString filename) {
  31 + Mat m(X.size(),1,CV_32FC1);
  32 + for (int i = 0; i < X.rows(); i++) {
  33 + m.at<float>(i,0) = (float)X(i);
  34 + }
  35 + QScopedPointer<br::Format> format(br::Factory<br::Format>::make(filename));
  36 + format->write(br::Template(m));
  37 +}
  38 +
  39 +void printEigen(Eigen::MatrixXd X) {
  40 + for (int i = 0; i < X.rows(); i++) {
  41 + QString str;
  42 + for (int j = 0; j < X.cols(); j++) {
  43 + str.append(QString::number(X(i,j)) + " ");
  44 + }
  45 + qDebug() << str;
  46 + }
  47 +}
openbr/core/eigenutils.h
@@ -22,6 +22,9 @@ @@ -22,6 +22,9 @@
22 #include <assert.h> 22 #include <assert.h>
23 23
24 void writeEigen(Eigen::MatrixXf X, QString filename); 24 void writeEigen(Eigen::MatrixXf X, QString filename);
  25 +void writeEigen(Eigen::MatrixXd X, QString filename);
  26 +void writeEigen(Eigen::VectorXd X, QString filename);
  27 +void printEigen(Eigen::MatrixXd X);
25 28
26 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> 29 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
27 inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) 30 inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat)
1 -Subproject commit b5c3cae0a3134f66b7668a8b928d39288f83b568 1 +Subproject commit aa2abb334a3179a04e14b713cd31f133d0c81321
openbr/janus.cpp
@@ -112,3 +112,14 @@ janus_error janus_verify(const janus_template a, const janus_template b, float * @@ -112,3 +112,14 @@ janus_error janus_verify(const janus_template a, const janus_template b, float *
112 *similarity = a_templates * b_templates / dist; 112 *similarity = a_templates * b_templates / dist;
113 return JANUS_SUCCESS; 113 return JANUS_SUCCESS;
114 } 114 }
  115 +
  116 +struct janus_incomplete_gallery_type
  117 +{
  118 + QList< QPair<janus_template, janus_template_id> > templates;
  119 +};
  120 +
  121 +janus_error janus_initialize_gallery(janus_incomplete_gallery *incomplete_gallery)
  122 +{
  123 + *incomplete_gallery = new janus_incomplete_gallery_type();
  124 + return JANUS_SUCCESS;
  125 +}
openbr/openbr_plugin.h
@@ -239,6 +239,13 @@ struct BR_EXPORT File @@ -239,6 +239,13 @@ struct BR_EXPORT File
239 return variant.value<T>(); 239 return variant.value<T>();
240 } 240 }
241 241
  242 + /*!< \brief Specialization for boolean type. */
  243 + template <bool>
  244 + bool get(const QString &key) const
  245 + {
  246 + return getBool(key);
  247 + }
  248 +
242 /*!< \brief Returns a value for the key, returning \em defaultValue if the key does not exist or can't be converted. */ 249 /*!< \brief Returns a value for the key, returning \em defaultValue if the key does not exist or can't be converted. */
243 template <typename T> 250 template <typename T>
244 T get(const QString &key, const T &defaultValue) const 251 T get(const QString &key, const T &defaultValue) const
@@ -250,6 +257,13 @@ struct BR_EXPORT File @@ -250,6 +257,13 @@ struct BR_EXPORT File
250 } 257 }
251 258
252 /*!< \brief Specialization for boolean type. */ 259 /*!< \brief Specialization for boolean type. */
  260 + template <bool>
  261 + bool get(const QString &key, const bool &defaultValue) const
  262 + {
  263 + return getBool(key, defaultValue);
  264 + }
  265 +
  266 + /*!< \brief Specialization for boolean type. */
253 bool getBool(const QString &key, bool defaultValue = false) const; 267 bool getBool(const QString &key, bool defaultValue = false) const;
254 268
255 /*!< \brief Specialization for list type. Returns a list of type T for the key, throwing an error if the key does not exist or if the value cannot be converted to the specified type. */ 269 /*!< \brief Specialization for list type. Returns a list of type T for the key, throwing an error if the key does not exist or if the value cannot be converted to the specified type. */
openbr/plugins/gallery.cpp
@@ -99,12 +99,12 @@ class galGallery : public Gallery @@ -99,12 +99,12 @@ class galGallery : public Gallery
99 void init() 99 void init()
100 { 100 {
101 gallery.setFileName(file); 101 gallery.setFileName(file);
102 - if (file.get<bool>("remove", false)) 102 + if (file.get<bool>("remove"))
103 gallery.remove(); 103 gallery.remove();
104 QtUtils::touchDir(gallery); 104 QtUtils::touchDir(gallery);
105 QFile::OpenMode mode = QFile::ReadWrite; 105 QFile::OpenMode mode = QFile::ReadWrite;
106 106
107 - if (file.contains("append")) 107 + if (file.get<bool>("append"))
108 mode |= QFile::Append; 108 mode |= QFile::Append;
109 109
110 if (!gallery.open(mode)) 110 if (!gallery.open(mode))
openbr/plugins/template.cpp
@@ -52,39 +52,23 @@ BR_REGISTER(Transform, RemoveTemplatesTransform) @@ -52,39 +52,23 @@ BR_REGISTER(Transform, RemoveTemplatesTransform)
52 52
53 /*! 53 /*!
54 * \ingroup transforms 54 * \ingroup transforms
55 - * \brief Filters a gallery based on the value of a metadata field. 55 + * \brief Removes a metadata field from all templates
56 * \author Brendan Klare \cite bklare 56 * \author Brendan Klare \cite bklare
57 */ 57 */
58 -class FilterOnMetadataTransform : public UntrainableMetaTransform 58 +class RemoveMetadataTransform : public UntrainableTransform
59 { 59 {
60 Q_OBJECT 60 Q_OBJECT
61 Q_PROPERTY(QString attributeName READ get_attributeName WRITE set_attributeName RESET reset_attributeName STORED false) 61 Q_PROPERTY(QString attributeName READ get_attributeName WRITE set_attributeName RESET reset_attributeName STORED false)
62 - Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false)  
63 - Q_PROPERTY(bool isGreaterThan READ get_isGreaterThan WRITE set_isGreaterThan RESET reset_isGreaterThan STORED false)  
64 - BR_PROPERTY(QString, attributeName, "Confidence")  
65 - BR_PROPERTY(float, threshold, 0)  
66 - BR_PROPERTY(bool, isGreaterThan, true)  
67 -  
68 - void project(const TemplateList &src, TemplateList &dst) const  
69 - {  
70 - QList<Template> filtered;  
71 - foreach (Template t, src) {  
72 - if (!t.file.contains(attributeName))  
73 - continue;  
74 - bool pass = t.file.get<float>(attributeName) > threshold;  
75 - if (isGreaterThan ? pass : !pass)  
76 - filtered.append(t);  
77 - }  
78 - dst = TemplateList(filtered);  
79 - } 62 + BR_PROPERTY(QString, attributeName, "None")
80 63
81 void project(const Template &src, Template &dst) const 64 void project(const Template &src, Template &dst) const
82 { 65 {
83 - (void) src; (void) dst; qFatal("shouldn't be here"); 66 + dst = src;
  67 + if (dst.file.contains(attributeName))
  68 + dst.file.remove(attributeName);
84 } 69 }
85 }; 70 };
86 -  
87 -BR_REGISTER(Transform, FilterOnMetadataTransform) 71 +BR_REGISTER(Transform, RemoveMetadataTransform)
88 72
89 } // namespace br 73 } // namespace br
90 74
scripts/lfpwToSigset.py
@@ -37,7 +37,7 @@ for lfpwType in [&#39;train&#39;,&#39;test&#39;]: @@ -37,7 +37,7 @@ for lfpwType in [&#39;train&#39;,&#39;test&#39;]:
37 if not os.path.exists('sigset'): 37 if not os.path.exists('sigset'):
38 os.mkdir('sigset') 38 os.mkdir('sigset')
39 out = open('sigset/%s.xml' % lfpwType,'w') 39 out = open('sigset/%s.xml' % lfpwType,'w')
40 - print >> out, xmlRoot.toprettyxml() 40 + out.write(xmlRoot.toprettyxml())
41 out.close() 41 out.close()
42 42
43 43