Commit 1f940027df4c884d54d246521c4942f825407a06

Authored by Josh Klontz
1 parent e41e406f

introduced confidence field to br_universal_template

openbr/plugins/gallery/binary.cpp
@@ -227,7 +227,7 @@ class utGallery : public BinaryGallery @@ -227,7 +227,7 @@ class utGallery : public BinaryGallery
227 } 227 }
228 228
229 t.file.set("AlgorithmID", ut.algorithmID); 229 t.file.set("AlgorithmID", ut.algorithmID);
230 - t.file.set("URL", QString(data.data())); 230 + t.file.set("Metadata", QString(data.data()));
231 char *dataStart = data.data() + ut.mdSize; 231 char *dataStart = data.data() + ut.mdSize;
232 uint32_t dataSize = ut.fvSize; 232 uint32_t dataSize = ut.fvSize;
233 if ((ut.algorithmID <= -1) && (ut.algorithmID >= -3)) { 233 if ((ut.algorithmID <= -1) && (ut.algorithmID >= -3)) {
@@ -243,8 +243,7 @@ class utGallery : public BinaryGallery @@ -243,8 +243,7 @@ class utGallery : public BinaryGallery
243 dataSize -= sizeof(uint32_t)*4; 243 dataSize -= sizeof(uint32_t)*4;
244 t.file.set("First_Eye", QPointF(*rightEyeX, *rightEyeY)); 244 t.file.set("First_Eye", QPointF(*rightEyeX, *rightEyeY));
245 t.file.set("Second_Eye", QPointF(*leftEyeX, *leftEyeY)); 245 t.file.set("Second_Eye", QPointF(*leftEyeX, *leftEyeY));
246 - }  
247 - else if (ut.algorithmID == 7) { 246 + } else if (ut.algorithmID == 7) {
248 // binary data consisting of a single channel matrix, of a supported type. 247 // binary data consisting of a single channel matrix, of a supported type.
249 // 4 element header: 248 // 4 element header:
250 // uint16 datatype (single channel opencv datatype code) 249 // uint16 datatype (single channel opencv datatype code)
@@ -272,6 +271,7 @@ class utGallery : public BinaryGallery @@ -272,6 +271,7 @@ class utGallery : public BinaryGallery
272 t.file.set("Y", ut.y); 271 t.file.set("Y", ut.y);
273 t.file.set("Width", ut.width); 272 t.file.set("Width", ut.width);
274 t.file.set("Height", ut.height); 273 t.file.set("Height", ut.height);
  274 + t.file.set("Confidence", ut.confidence);
275 275
276 t.append(cv::Mat(matrixRows, matrixCols, CV_MAKETYPE(dataType, matrixDepth), dataStart).clone() /* We don't want a shallow copy! */); 276 t.append(cv::Mat(matrixRows, matrixCols, CV_MAKETYPE(dataType, matrixDepth), dataStart).clone() /* We don't want a shallow copy! */);
277 return t; 277 return t;
@@ -280,6 +280,7 @@ class utGallery : public BinaryGallery @@ -280,6 +280,7 @@ class utGallery : public BinaryGallery
280 t.file.set("Y", ut.y); 280 t.file.set("Y", ut.y);
281 t.file.set("Width", ut.width); 281 t.file.set("Width", ut.width);
282 t.file.set("Height", ut.height); 282 t.file.set("Height", ut.height);
  283 + t.file.set("Confidence", ut.confidence);
283 } 284 }
284 t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */); 285 t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */);
285 } else { 286 } else {
@@ -300,6 +301,7 @@ class utGallery : public BinaryGallery @@ -300,6 +301,7 @@ class utGallery : public BinaryGallery
300 301
301 int32_t x = 0, y = 0; 302 int32_t x = 0, y = 0;
302 uint32_t width = 0, height = 0; 303 uint32_t width = 0, height = 0;
  304 + float confidence = 0;
303 QByteArray header; 305 QByteArray header;
304 if ((algorithmID <= -1) && (algorithmID >= -3)) { 306 if ((algorithmID <= -1) && (algorithmID >= -3)) {
305 const QRectF frontalFace = t.file.get<QRectF>("FrontalFace"); 307 const QRectF frontalFace = t.file.get<QRectF>("FrontalFace");
@@ -324,6 +326,7 @@ class utGallery : public BinaryGallery @@ -324,6 +326,7 @@ class utGallery : public BinaryGallery
324 y = t.file.get<int32_t>("Y", 0); 326 y = t.file.get<int32_t>("Y", 0);
325 width = t.file.get<uint32_t>("Width", 0); 327 width = t.file.get<uint32_t>("Width", 0);
326 height = t.file.get<uint32_t>("Height", 0); 328 height = t.file.get<uint32_t>("Height", 0);
  329 + confidence = t.file.get<uint32_t>("Confidence", 0);
327 } 330 }
328 331
329 gallery.write((const char*) &algorithmID, sizeof(int32_t)); 332 gallery.write((const char*) &algorithmID, sizeof(int32_t));
@@ -331,6 +334,7 @@ class utGallery : public BinaryGallery @@ -331,6 +334,7 @@ class utGallery : public BinaryGallery
331 gallery.write((const char*) &y , sizeof(int32_t)); 334 gallery.write((const char*) &y , sizeof(int32_t));
332 gallery.write((const char*) &width , sizeof(uint32_t)); 335 gallery.write((const char*) &width , sizeof(uint32_t));
333 gallery.write((const char*) &height , sizeof(uint32_t)); 336 gallery.write((const char*) &height , sizeof(uint32_t));
  337 + gallery.write((const char*) &confidence , sizeof(float));
334 338
335 const uint32_t mdSize = metadata.size() + 1; 339 const uint32_t mdSize = metadata.size() + 1;
336 gallery.write((const char*) &mdSize, sizeof(uint32_t)); 340 gallery.write((const char*) &mdSize, sizeof(uint32_t));
openbr/universal_template.cpp
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 #include "universal_template.h" 9 #include "universal_template.h"
10 10
11 -br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_t width, uint32_t height, const char *metadata, const char *featureVector, uint32_t fvSize) 11 +br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_t width, uint32_t height, float confidence, const char *metadata, const char *featureVector, uint32_t fvSize)
12 { 12 {
13 const uint32_t mdSize = strlen(metadata) + 1; 13 const uint32_t mdSize = strlen(metadata) + 1;
14 br_utemplate utemplate = (br_utemplate) malloc(sizeof(br_universal_template) + mdSize + fvSize); 14 br_utemplate utemplate = (br_utemplate) malloc(sizeof(br_universal_template) + mdSize + fvSize);
@@ -17,6 +17,7 @@ br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_ @@ -17,6 +17,7 @@ br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_
17 utemplate->y = y; 17 utemplate->y = y;
18 utemplate->width = width; 18 utemplate->width = width;
19 utemplate->height = height; 19 utemplate->height = height;
  20 + utemplate->confidence = confidence;
20 utemplate->mdSize = mdSize; 21 utemplate->mdSize = mdSize;
21 utemplate->fvSize = fvSize; 22 utemplate->fvSize = fvSize;
22 memcpy(reinterpret_cast<char*>(utemplate+1) + 0, metadata , mdSize); 23 memcpy(reinterpret_cast<char*>(utemplate+1) + 0, metadata , mdSize);
openbr/universal_template.h
@@ -40,6 +40,7 @@ struct br_universal_template @@ -40,6 +40,7 @@ struct br_universal_template
40 int32_t y; /*!< Region of interest vertical offset (pixels). */ 40 int32_t y; /*!< Region of interest vertical offset (pixels). */
41 uint32_t width; /*!< Region of interest horizontal size (pixels). */ 41 uint32_t width; /*!< Region of interest horizontal size (pixels). */
42 uint32_t height; /*!< Region of interest vertical size (pixels). */ 42 uint32_t height; /*!< Region of interest vertical size (pixels). */
  43 + float confidence; /*!< Region of interest confidence. */
43 uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_, 44 uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_,
44 including the null-terminator character itself. */ 45 including the null-terminator character itself. */
45 uint32_t fvSize; /*!< Length of the feature vector after the metadata in _data_. */ 46 uint32_t fvSize; /*!< Length of the feature vector after the metadata in _data_. */
@@ -55,7 +56,7 @@ typedef const struct br_universal_template *br_const_utemplate; @@ -55,7 +56,7 @@ typedef const struct br_universal_template *br_const_utemplate;
55 * \brief br_universal_template constructor. 56 * \brief br_universal_template constructor.
56 * \see br_free_utemplate 57 * \see br_free_utemplate
57 */ 58 */
58 -BR_EXPORT br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t label, const char *metadata, const char *featureVector, uint32_t fvSize); 59 +BR_EXPORT br_utemplate br_new_utemplate(int32_t algorithmID, int32_t x, int32_t y, uint32_t width, uint32_t height, float confidence, const char *metadata, const char *featureVector, uint32_t fvSize);
59 60
60 /*! 61 /*!
61 * \brief br_universal_template destructor. 62 * \brief br_universal_template destructor.