Commit 217b09f7db9b925cd5586f703707b5ec0d5fac28

Authored by M Taborsky
1 parent 20cdcd94

added backProject to Context and Transform

sdk/openbr_plugin.cpp
... ... @@ -606,6 +606,7 @@ br::Context::Context()
606 606 quiet = verbose = false;
607 607 currentStep = totalSteps = 0;
608 608 enrollAll = false;
  609 + backProject = false;
609 610 }
610 611  
611 612 int br::Context::blocks(int size) const
... ... @@ -1046,6 +1047,8 @@ private:
1046 1047 }
1047 1048 }
1048 1049  
  1050 +
  1051 +
1049 1052 void store(QDataStream &stream) const
1050 1053 {
1051 1054 const int size = transforms.size();
... ... @@ -1154,6 +1157,12 @@ void Transform::project(const TemplateList &src, TemplateList &dst) const
1154 1157 if (Globals->parallelism) Globals->trackFutures(futures);
1155 1158 }
1156 1159  
  1160 +void Transform::backProject(const Template &dst, Template &src) const
  1161 +{
  1162 + src = dst;
  1163 +}
  1164 +
  1165 +
1157 1166 /* Distance - public methods */
1158 1167 void Distance::train(const TemplateList &templates)
1159 1168 {
... ...
sdk/openbr_plugin.h
... ... @@ -449,6 +449,13 @@ public:
449 449 BR_PROPERTY(int, parallelism, 0)
450 450  
451 451 /*!
  452 + * \brief true if backProject should be used instead of project (the algorithm should be inverted)
  453 + */
  454 + Q_PROPERTY(bool backProject READ get_backProject WRITE set_backProject RESET reset_backProject)
  455 + BR_PROPERTY(bool, backProject, false)
  456 +
  457 +
  458 + /*!
452 459 * \brief If \c true no messages will be sent to the terminal, \c false by default.
453 460 */
454 461 Q_PROPERTY(bool quiet READ get_quiet WRITE set_quiet RESET reset_quiet)
... ... @@ -905,6 +912,9 @@ public:
905 912 virtual void train(const TemplateList &data) = 0; /*!< \brief Train the transform. */
906 913 virtual void project(const Template &src, Template &dst) const = 0; /*!< \brief Apply the transform. */
907 914 virtual void project(const TemplateList &src, TemplateList &dst) const; /*!< \brief Apply the transform. */
  915 + virtual void backProject(const Template &dst, Template &src) const; /*!< \brief Invert the transform. */
  916 +
  917 +
908 918  
909 919 /*!
910 920 * \brief Convenience function equivalent to project().
... ... @@ -930,6 +940,7 @@ public:
930 940 protected:
931 941 Transform(bool independent = true); /*!< \brief Construct a transform. */
932 942 inline Transform *make(const QString &description) { return make(description, this); } /*!< \brief Make a subtransform. */
  943 +
933 944 };
934 945  
935 946 /*!
... ... @@ -996,6 +1007,7 @@ private:
996 1007 void load(QDataStream &stream) { (void) stream; }
997 1008 };
998 1009  
  1010 +
999 1011 /*!
1000 1012 * \brief A br::MetaTransform that does not require training data.
1001 1013 */
... ... @@ -1043,7 +1055,7 @@ private:
1043 1055 * \brief Returns \c true if the algorithm is a classifier, \c false otherwise.
1044 1056 *
1045 1057 * Classifers have no br::Distance associated with their br::Transform.
1046   -* Instead they populate br::Template::file \c Label metadata fielf with the predicted class.
  1058 +* Instead they populate br::Template::file \c Label metadata field with the predicted class.
1047 1059 */
1048 1060 BR_EXPORT bool IsClassifier(const QString &algorithm);
1049 1061  
... ...