Commit 61704511f600d4761b1ee9d35d38473db31e4e8c

Authored by Austin Blanton
1 parent c3fff4cf

Add File::setList to automatically convert QLists to QVariantLists

openbr/openbr_plugin.h
... ... @@ -41,6 +41,7 @@
41 41 #include <QVector>
42 42 #include <opencv2/core/core.hpp>
43 43 #include <openbr/openbr.h>
  44 +#include <openbr/core/qtutils.h>
44 45  
45 46 /*!
46 47 * \defgroup cpp_plugin_sdk C++ Plugin SDK
... ... @@ -215,6 +216,14 @@ struct BR_EXPORT File
215 216 static QVariant parse(const QString &value); /*!< \brief Try to convert the QString to a QPointF or QRectF if possible. */
216 217 inline void set(const QString &key, const QVariant &value) { m_metadata.insert(key, value); } /*!< \brief Insert or overwrite the metadata key with the specified value. */
217 218 void set(const QString &key, const QString &value); /*!< \brief Insert or overwrite the metadata key with the specified value. */
  219 +
  220 + /*!< \brief Specialization for list type. Insert or overwrite the metadata key with the specified value. */
  221 + template <typename T>
  222 + void setList(const QString &key, const QList<T> &value)
  223 + {
  224 + set(key, QtUtils::toVariantList(value));
  225 + }
  226 +
218 227 inline void remove(const QString &key) { m_metadata.remove(key); } /*!< \brief Remove the metadata key. */
219 228  
220 229 /*!< \brief Returns a value for the key, throwing an error if the key does not exist. */
... ...
openbr/plugins/landmarks.cpp
... ... @@ -113,7 +113,7 @@ class ProcrustesTransform : public Transform
113 113 // R(0,0), R(1,0), R(1,1), R(0,1), mean_x, mean_y, norm
114 114 QList<float> procrustesStats;
115 115 procrustesStats << R(0,0) << R(1,0) << R(1,1) << R(0,1) << mean[0] << mean[1] << norm;
116   - dst.file.set("ProcrustesStats",QtUtils::toVariantList(procrustesStats));
  116 + dst.file.setList<float>("ProcrustesStats",procrustesStats);
117 117  
118 118 if (warp) {
119 119 Eigen::MatrixXf dstMat = srcMat*R;
... ... @@ -273,7 +273,7 @@ class DelaunayTransform : public UntrainableTransform
273 273 dst.file.setRects(QList<QRectF>() << OpenCVUtils::fromRect(boundingBox));
274 274 } else dst = src;
275 275  
276   - dst.file.set("DelaunayTriangles", QtUtils::toVariantList(validTriangles));
  276 + dst.file.setList<QPointF>("DelaunayTriangles", validTriangles);
277 277 }
278 278 };
279 279  
... ...
openbr/plugins/slidingwindow.cpp
... ... @@ -120,7 +120,7 @@ private:
120 120 if (dst.file.contains("Confidences"))
121 121 confidences = dst.file.getList<float>("Confidences");
122 122 confidences.append(confidence);
123   - dst.file.set("Confidences", QtUtils::toVariantList(confidences));
  123 + dst.file.setList<float>("Confidences", confidences);
124 124 if (takeLargestScale) return;
125 125 }
126 126 }
... ...