diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 68b9066..82e5e15 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -410,7 +410,6 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) } else if (newTemplates[i].file.getBool("allPartitions")) { // The allPartitions flag is used to add an extended set // of target images to every partition - newTemplates[i].file.set("Partition", -1); } else { const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.get("Subject").toLatin1(), QCryptographicHash::Md5); diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp new file mode 100644 index 0000000..dd5f88d --- /dev/null +++ b/openbr/plugins/template.cpp @@ -0,0 +1,30 @@ +#include "openbr_internal.h" + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Retains only the values for the keys listed, to reduce template size + * \author Scott Klum \cite sklum + */ +class RetainTransform : public UntrainableTransform +{ + Q_OBJECT + Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false) + BR_PROPERTY(QStringList, keys, QStringList()) + + void project(const Template &src, Template &dst) const + { + dst = src; + foreach(const QString& localKey, dst.file.localKeys()) { + if (!keys.contains(localKey)) dst.file.remove(localKey); + } + } +}; + +BR_REGISTER(Transform, RetainTransform) + +} // namespace br + +#include "template.moc" diff --git a/openbr/plugins/validate.cpp b/openbr/plugins/validate.cpp index 9166f3f..68c603e 100644 --- a/openbr/plugins/validate.cpp +++ b/openbr/plugins/validate.cpp @@ -157,11 +157,11 @@ class MetadataDistance : public Distance if (aValue[0] == '(') /* Range */ { QStringList values = aValue.split(','); - int age = values[0].mid(1).toInt(); + int value = values[0].mid(1).toInt(); values[1].chop(1); int upperBound = values[1].toInt(); - while (age <= upperBound) { + while (value <= upperBound) { if (aValue == bValue) { keep = true; break;