diff --git a/openbr/core/eigenutils.cpp b/openbr/core/eigenutils.cpp index ce75b65..4e1d939 100644 --- a/openbr/core/eigenutils.cpp +++ b/openbr/core/eigenutils.cpp @@ -16,4 +16,32 @@ void writeEigen(MatrixXf X, QString filename) { format->write(br::Template(m)); } +void writeEigen(MatrixXd X, QString filename) { + Mat m(X.rows(),X.cols(),CV_32FC1); + for (int i = 0; i < X.rows(); i++) { + for (int j = 0; j < X.cols(); j++) { + m.at(i,j) = (float)X(i,j); + } + } + QScopedPointer format(br::Factory::make(filename)); + format->write(br::Template(m)); +} +void writeEigen(VectorXd X, QString filename) { + Mat m(X.size(),1,CV_32FC1); + for (int i = 0; i < X.rows(); i++) { + m.at(i,0) = (float)X(i); + } + QScopedPointer format(br::Factory::make(filename)); + format->write(br::Template(m)); +} + +void printEigen(Eigen::MatrixXd X) { + for (int i = 0; i < X.rows(); i++) { + QString str; + for (int j = 0; j < X.cols(); j++) { + str.append(QString::number(X(i,j)) + " "); + } + qDebug() << str; + } +} diff --git a/openbr/core/eigenutils.h b/openbr/core/eigenutils.h index 314060a..5d4ab62 100644 --- a/openbr/core/eigenutils.h +++ b/openbr/core/eigenutils.h @@ -22,6 +22,9 @@ #include void writeEigen(Eigen::MatrixXf X, QString filename); +void writeEigen(Eigen::MatrixXd X, QString filename); +void writeEigen(Eigen::VectorXd X, QString filename); +void printEigen(Eigen::MatrixXd X); template inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) diff --git a/openbr/janus b/openbr/janus index b5c3cae..aa2abb3 160000 --- a/openbr/janus +++ b/openbr/janus @@ -1 +1 @@ -Subproject commit b5c3cae0a3134f66b7668a8b928d39288f83b568 +Subproject commit aa2abb334a3179a04e14b713cd31f133d0c81321 diff --git a/openbr/janus.cpp b/openbr/janus.cpp index b5f6e4f..fa010d2 100644 --- a/openbr/janus.cpp +++ b/openbr/janus.cpp @@ -112,3 +112,14 @@ janus_error janus_verify(const janus_template a, const janus_template b, float * *similarity = a_templates * b_templates / dist; return JANUS_SUCCESS; } + +struct janus_incomplete_gallery_type +{ + QList< QPair > templates; +}; + +janus_error janus_initialize_gallery(janus_incomplete_gallery *incomplete_gallery) +{ + *incomplete_gallery = new janus_incomplete_gallery_type(); + return JANUS_SUCCESS; +} diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 1d9f7cd..30f3799 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -239,6 +239,13 @@ struct BR_EXPORT File return variant.value(); } + /*!< \brief Specialization for boolean type. */ + template + bool get(const QString &key) const + { + return getBool(key); + } + /*!< \brief Returns a value for the key, returning \em defaultValue if the key does not exist or can't be converted. */ template T get(const QString &key, const T &defaultValue) const @@ -250,6 +257,13 @@ struct BR_EXPORT File } /*!< \brief Specialization for boolean type. */ + template + bool get(const QString &key, const bool &defaultValue) const + { + return getBool(key, defaultValue); + } + + /*!< \brief Specialization for boolean type. */ bool getBool(const QString &key, bool defaultValue = false) const; /*!< \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. */ diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index 6d02436..bb1b4f2 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -99,12 +99,12 @@ class galGallery : public Gallery void init() { gallery.setFileName(file); - if (file.get("remove", false)) + if (file.get("remove")) gallery.remove(); QtUtils::touchDir(gallery); QFile::OpenMode mode = QFile::ReadWrite; - if (file.contains("append")) + if (file.get("append")) mode |= QFile::Append; if (!gallery.open(mode)) diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp index 2cd7c61..fdffab5 100644 --- a/openbr/plugins/template.cpp +++ b/openbr/plugins/template.cpp @@ -52,39 +52,23 @@ BR_REGISTER(Transform, RemoveTemplatesTransform) /*! * \ingroup transforms - * \brief Filters a gallery based on the value of a metadata field. + * \brief Removes a metadata field from all templates * \author Brendan Klare \cite bklare */ -class FilterOnMetadataTransform : public UntrainableMetaTransform +class RemoveMetadataTransform : public UntrainableTransform { Q_OBJECT Q_PROPERTY(QString attributeName READ get_attributeName WRITE set_attributeName RESET reset_attributeName STORED false) - Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false) - Q_PROPERTY(bool isGreaterThan READ get_isGreaterThan WRITE set_isGreaterThan RESET reset_isGreaterThan STORED false) - BR_PROPERTY(QString, attributeName, "Confidence") - BR_PROPERTY(float, threshold, 0) - BR_PROPERTY(bool, isGreaterThan, true) - - void project(const TemplateList &src, TemplateList &dst) const - { - QList