Commit e89ad62dffbd7a5c5ef68d2026e32e8640875a5a
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
5 changed files
with
30 additions
and
11 deletions
openbr/core/core.cpp
| ... | ... | @@ -490,9 +490,18 @@ void br::Cat(const QStringList &inputGalleries, const QString &outputGallery) |
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | -QSharedPointer<br::Transform> br::Transform::fromAlgorithm(const QString &algorithm) | |
| 493 | +QSharedPointer<br::Transform> br::Transform::fromAlgorithm(const QString &algorithm, bool preprocess) | |
| 494 | 494 | { |
| 495 | - return AlgorithmManager::getAlgorithm(algorithm)->transform; | |
| 495 | + if (!preprocess) | |
| 496 | + return AlgorithmManager::getAlgorithm(algorithm)->transform; | |
| 497 | + else { | |
| 498 | + QSharedPointer<Transform> orig_tform = AlgorithmManager::getAlgorithm(algorithm)->transform; | |
| 499 | + QSharedPointer<Transform> newRoot = QSharedPointer<Transform>(Transform::make("Stream(Identity)", NULL)); | |
| 500 | + WrapperTransform * downcast = dynamic_cast<WrapperTransform *> (newRoot.data()); | |
| 501 | + downcast->transform = orig_tform.data(); | |
| 502 | + downcast->init(); | |
| 503 | + return newRoot; | |
| 504 | + } | |
| 496 | 505 | } |
| 497 | 506 | |
| 498 | 507 | QSharedPointer<br::Distance> br::Distance::fromAlgorithm(const QString &algorithm) | ... | ... |
openbr/openbr_plugin.h
| ... | ... | @@ -1105,7 +1105,7 @@ public: |
| 1105 | 1105 | |
| 1106 | 1106 | virtual ~Transform() {} |
| 1107 | 1107 | static Transform *make(QString str, QObject *parent); /*!< \brief Make a transform from a string. */ |
| 1108 | - static QSharedPointer<Transform> fromAlgorithm(const QString &algorithm); /*!< \brief Retrieve an algorithm's transform. */ | |
| 1108 | + static QSharedPointer<Transform> fromAlgorithm(const QString &algorithm, bool preprocess=true); /*!< \brief Retrieve an algorithm's transform. If preprocess is true, attaches a stream transform as the root of the algorithm*/ | |
| 1109 | 1109 | |
| 1110 | 1110 | virtual Transform *clone() const; /*!< \brief Copy the transform. */ |
| 1111 | 1111 | |
| ... | ... | @@ -1124,6 +1124,7 @@ public: |
| 1124 | 1124 | |
| 1125 | 1125 | /*!< \brief Apply the transform to a single template. Typically used by independent transforms */ |
| 1126 | 1126 | virtual void project(const Template &src, Template &dst) const = 0; |
| 1127 | + | |
| 1127 | 1128 | /*!< \brief Apply the transform, taking the full template list as input. |
| 1128 | 1129 | * A TemplateList is what is typically passed from transform to transform. Transforms that just |
| 1129 | 1130 | * need to operatoe on a single template at a time (and want to output exactly 1 template) can implement | ... | ... |
openbr/plugins/draw.cpp
| ... | ... | @@ -336,8 +336,7 @@ class AdjacentOverlayTransform : public Transform |
| 336 | 336 | |
| 337 | 337 | void init() |
| 338 | 338 | { |
| 339 | - opener = br::Transform::fromAlgorithm("Cache(Open)"); | |
| 340 | - | |
| 339 | + opener = QSharedPointer<br::Transform>(br::Transform::make("Cache(Open)", NULL)); | |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | }; | ... | ... |
openbr/plugins/meta.cpp
| ... | ... | @@ -248,8 +248,8 @@ class ExpandTransform : public UntrainableMetaTransform |
| 248 | 248 | |
| 249 | 249 | virtual void project(const Template & src, Template & dst) const |
| 250 | 250 | { |
| 251 | - qFatal("this has gone bad"); | |
| 252 | - (void) src; (void) dst; | |
| 251 | + dst = src; | |
| 252 | + qDebug("Called Expand project(Template,Template), nothing will happen"); | |
| 253 | 253 | } |
| 254 | 254 | }; |
| 255 | 255 | ... | ... |
openbr/plugins/stream.cpp
| ... | ... | @@ -1007,14 +1007,24 @@ public: |
| 1007 | 1007 | |
| 1008 | 1008 | void project(const Template &src, Template &dst) const |
| 1009 | 1009 | { |
| 1010 | - (void) src; (void) dst; | |
| 1011 | - qFatal("nope"); | |
| 1010 | + TemplateList in; | |
| 1011 | + in.append(src); | |
| 1012 | + TemplateList out; | |
| 1013 | + CompositeTransform::project(in,out); | |
| 1014 | + dst = out.first(); | |
| 1015 | + if (out.size() > 1) | |
| 1016 | + qDebug("Returning first output template only"); | |
| 1012 | 1017 | } |
| 1013 | 1018 | |
| 1014 | 1019 | void projectUpdate(const Template &src, Template &dst) |
| 1015 | 1020 | { |
| 1016 | - (void) src; (void) dst; | |
| 1017 | - qFatal("whatever"); | |
| 1021 | + TemplateList in; | |
| 1022 | + in.append(src); | |
| 1023 | + TemplateList out; | |
| 1024 | + projectUpdate(in,out); | |
| 1025 | + dst = out.first(); | |
| 1026 | + if (out.size() > 1) | |
| 1027 | + qDebug("Returning first output template only"); | |
| 1018 | 1028 | } |
| 1019 | 1029 | |
| 1020 | 1030 | ... | ... |