diff --git a/sdk/openbr_plugin.cpp b/sdk/openbr_plugin.cpp index f8a4ea0..f91fc90 100644 --- a/sdk/openbr_plugin.cpp +++ b/sdk/openbr_plugin.cpp @@ -606,6 +606,7 @@ br::Context::Context() quiet = verbose = false; currentStep = totalSteps = 0; enrollAll = false; + backProject = false; } int br::Context::blocks(int size) const @@ -1046,6 +1047,8 @@ private: } } + + void store(QDataStream &stream) const { const int size = transforms.size(); @@ -1154,6 +1157,12 @@ void Transform::project(const TemplateList &src, TemplateList &dst) const if (Globals->parallelism) Globals->trackFutures(futures); } +void Transform::backProject(const Template &dst, Template &src) const +{ + src = dst; +} + + /* Distance - public methods */ void Distance::train(const TemplateList &templates) { diff --git a/sdk/openbr_plugin.h b/sdk/openbr_plugin.h index 2ba1cd6..08f008b 100644 --- a/sdk/openbr_plugin.h +++ b/sdk/openbr_plugin.h @@ -449,6 +449,13 @@ public: BR_PROPERTY(int, parallelism, 0) /*! + * \brief true if backProject should be used instead of project (the algorithm should be inverted) + */ + Q_PROPERTY(bool backProject READ get_backProject WRITE set_backProject RESET reset_backProject) + BR_PROPERTY(bool, backProject, false) + + + /*! * \brief If \c true no messages will be sent to the terminal, \c false by default. */ Q_PROPERTY(bool quiet READ get_quiet WRITE set_quiet RESET reset_quiet) @@ -905,6 +912,9 @@ public: virtual void train(const TemplateList &data) = 0; /*!< \brief Train the transform. */ virtual void project(const Template &src, Template &dst) const = 0; /*!< \brief Apply the transform. */ virtual void project(const TemplateList &src, TemplateList &dst) const; /*!< \brief Apply the transform. */ + virtual void backProject(const Template &dst, Template &src) const; /*!< \brief Invert the transform. */ + + /*! * \brief Convenience function equivalent to project(). @@ -930,6 +940,7 @@ public: protected: Transform(bool independent = true); /*!< \brief Construct a transform. */ inline Transform *make(const QString &description) { return make(description, this); } /*!< \brief Make a subtransform. */ + }; /*! @@ -996,6 +1007,7 @@ private: void load(QDataStream &stream) { (void) stream; } }; + /*! * \brief A br::MetaTransform that does not require training data. */ @@ -1043,7 +1055,7 @@ private: * \brief Returns \c true if the algorithm is a classifier, \c false otherwise. * * Classifers have no br::Distance associated with their br::Transform. -* Instead they populate br::Template::file \c Label metadata fielf with the predicted class. +* Instead they populate br::Template::file \c Label metadata field with the predicted class. */ BR_EXPORT bool IsClassifier(const QString &algorithm);