From a01f3b9bf3eb6438b269eb6119f4e110c24b3456 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Fri, 13 Jun 2014 12:04:56 -0400 Subject: [PATCH] implemented JSONTransform --- openbr/plugins/template.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 */ -- libgit2 0.21.4