diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp index 203fc9d..1b26511 100644 --- a/openbr/plugins/template.cpp +++ b/openbr/plugins/template.cpp @@ -1,5 +1,6 @@ +#include + #include "openbr_internal.h" -#include namespace br { @@ -96,6 +97,25 @@ BR_REGISTER(Transform, IfMetadataTransform) /*! * \ingroup transforms + * \brief Represent the metadata as JSON template data. + * \author Josh Klontz \cite jklontz + */ +class JSONTransform : public UntrainableMetaTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + dst.file = src.file; + const QByteArray json = QJsonDocument(QJsonObject::fromVariantMap(src.file.localMetadata())).toJson(QJsonDocument::Compact); + dst += cv::Mat(1, json.size(), CV_8UC1, (void*) json.data()); + } +}; + +BR_REGISTER(Transform, JSONTransform) + +/*! + * \ingroup transforms * \brief Removes a metadata field from all templates * \author Brendan Klare \cite bklare */