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