diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index cea16f1..2afb530 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -490,9 +490,18 @@ void br::Cat(const QStringList &inputGalleries, const QString &outputGallery) } } -QSharedPointer br::Transform::fromAlgorithm(const QString &algorithm) +QSharedPointer br::Transform::fromAlgorithm(const QString &algorithm, bool preprocess) { - return AlgorithmManager::getAlgorithm(algorithm)->transform; + if (!preprocess) + return AlgorithmManager::getAlgorithm(algorithm)->transform; + else { + QSharedPointer orig_tform = AlgorithmManager::getAlgorithm(algorithm)->transform; + QSharedPointer newRoot = QSharedPointer(Transform::make("Stream(Identity)", NULL)); + WrapperTransform * downcast = dynamic_cast (newRoot.data()); + downcast->transform = orig_tform.data(); + downcast->init(); + return newRoot; + } } QSharedPointer br::Distance::fromAlgorithm(const QString &algorithm) diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index f9acbf8..60a13e6 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1105,7 +1105,7 @@ public: virtual ~Transform() {} static Transform *make(QString str, QObject *parent); /*!< \brief Make a transform from a string. */ - static QSharedPointer fromAlgorithm(const QString &algorithm); /*!< \brief Retrieve an algorithm's transform. */ + static QSharedPointer 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*/ virtual Transform *clone() const; /*!< \brief Copy the transform. */ @@ -1124,6 +1124,7 @@ public: /*!< \brief Apply the transform to a single template. Typically used by independent transforms */ virtual void project(const Template &src, Template &dst) const = 0; + /*!< \brief Apply the transform, taking the full template list as input. * A TemplateList is what is typically passed from transform to transform. Transforms that just * need to operatoe on a single template at a time (and want to output exactly 1 template) can implement diff --git a/openbr/plugins/draw.cpp b/openbr/plugins/draw.cpp index 49f8ca6..3057b8a 100644 --- a/openbr/plugins/draw.cpp +++ b/openbr/plugins/draw.cpp @@ -336,8 +336,7 @@ class AdjacentOverlayTransform : public Transform void init() { - opener = br::Transform::fromAlgorithm("Cache(Open)"); - + opener = QSharedPointer(br::Transform::make("Cache(Open)", NULL)); } }; diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index 7d61341..19aa56b 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -248,8 +248,8 @@ class ExpandTransform : public UntrainableMetaTransform virtual void project(const Template & src, Template & dst) const { - qFatal("this has gone bad"); - (void) src; (void) dst; + dst = src; + qDebug("Called Expand project(Template,Template), nothing will happen"); } }; diff --git a/openbr/plugins/stream.cpp b/openbr/plugins/stream.cpp index 65c3501..56f8b55 100644 --- a/openbr/plugins/stream.cpp +++ b/openbr/plugins/stream.cpp @@ -1007,14 +1007,24 @@ public: void project(const Template &src, Template &dst) const { - (void) src; (void) dst; - qFatal("nope"); + TemplateList in; + in.append(src); + TemplateList out; + CompositeTransform::project(in,out); + dst = out.first(); + if (out.size() > 1) + qDebug("Returning first output template only"); } void projectUpdate(const Template &src, Template &dst) { - (void) src; (void) dst; - qFatal("whatever"); + TemplateList in; + in.append(src); + TemplateList out; + projectUpdate(in,out); + dst = out.first(); + if (out.size() > 1) + qDebug("Returning first output template only"); }