Commit a01f3b9bf3eb6438b269eb6119f4e110c24b3456

Authored by Josh Klontz
1 parent 318e194d

implemented JSONTransform

Showing 1 changed file with 21 additions and 1 deletions
openbr/plugins/template.cpp
  1 +#include <QtCore>
  2 +
1 3 #include "openbr_internal.h"
2   -#include <QRegularExpression>
3 4  
4 5 namespace br
5 6 {
... ... @@ -96,6 +97,25 @@ BR_REGISTER(Transform, IfMetadataTransform)
96 97  
97 98 /*!
98 99 * \ingroup transforms
  100 + * \brief Represent the metadata as JSON template data.
  101 + * \author Josh Klontz \cite jklontz
  102 + */
  103 +class JSONTransform : public UntrainableMetaTransform
  104 +{
  105 + Q_OBJECT
  106 +
  107 + void project(const Template &src, Template &dst) const
  108 + {
  109 + dst.file = src.file;
  110 + const QByteArray json = QJsonDocument(QJsonObject::fromVariantMap(src.file.localMetadata())).toJson(QJsonDocument::Compact);
  111 + dst += cv::Mat(1, json.size(), CV_8UC1, (void*) json.data());
  112 + }
  113 +};
  114 +
  115 +BR_REGISTER(Transform, JSONTransform)
  116 +
  117 +/*!
  118 + * \ingroup transforms
99 119 * \brief Removes a metadata field from all templates
100 120 * \author Brendan Klare \cite bklare
101 121 */
... ...