diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp index 7ef2846..b771c4f 100644 --- a/openbr/plugins/template.cpp +++ b/openbr/plugins/template.cpp @@ -176,6 +176,37 @@ class SelectPointsTransform : public UntrainableMetadataTransform BR_REGISTER(Transform, SelectPointsTransform) +/*! + * \ingroup transforms + * \brief Removes duplicate templates based on a unique metadata key + * \author Austin Blanton \cite imaus10 + */ +class FilterDupeMetadataTransform : public TimeVaryingTransform +{ + Q_OBJECT + + Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) + BR_PROPERTY(QString, key, "TemplateID") + + QSet excluded; + + void projectUpdate(const TemplateList &src, TemplateList &dst) + { + foreach (const Template &t, src) { + QString id = t.file.get(key); + if (!excluded.contains(id)) { + dst.append(t); + excluded.insert(id); + } + } + } + +public: + FilterDupeMetadataTransform() : TimeVaryingTransform(false,false) {} +}; + +BR_REGISTER(Transform, FilterDupeMetadataTransform) + } // namespace br #include "template.moc"