From 1f940027df4c884d54d246521c4942f825407a06 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Mon, 8 Jun 2015 16:46:20 -0400 Subject: [PATCH] introduced confidence field to br_universal_template --- openbr/plugins/gallery/binary.cpp | 10 +++++++--- openbr/universal_template.cpp | 3 ++- openbr/universal_template.h | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/openbr/plugins/gallery/binary.cpp b/openbr/plugins/gallery/binary.cpp index 05fd5fc..89bb3e3 100644 --- a/openbr/plugins/gallery/binary.cpp +++ b/openbr/plugins/gallery/binary.cpp @@ -227,7 +227,7 @@ class utGallery : public BinaryGallery } t.file.set("AlgorithmID", ut.algorithmID); - t.file.set("URL", QString(data.data())); + t.file.set("Metadata", QString(data.data())); char *dataStart = data.data() + ut.mdSize; uint32_t dataSize = ut.fvSize; if ((ut.algorithmID <= -1) && (ut.algorithmID >= -3)) { @@ -243,8 +243,7 @@ class utGallery : public BinaryGallery dataSize -= sizeof(uint32_t)*4; t.file.set("First_Eye", QPointF(*rightEyeX, *rightEyeY)); t.file.set("Second_Eye", QPointF(*leftEyeX, *leftEyeY)); - } - else if (ut.algorithmID == 7) { + } else if (ut.algorithmID == 7) { // binary data consisting of a single channel matrix, of a supported type. // 4 element header: // uint16 datatype (single channel opencv datatype code) @@ -272,6 +271,7 @@ class utGallery : public BinaryGallery t.file.set("Y", ut.y); t.file.set("Width", ut.width); t.file.set("Height", ut.height); + t.file.set("Confidence", ut.confidence); t.append(cv::Mat(matrixRows, matrixCols, CV_MAKETYPE(dataType, matrixDepth), dataStart).clone() /* We don't want a shallow copy! */); return t; @@ -280,6 +280,7 @@ class utGallery : public BinaryGallery t.file.set("Y", ut.y); t.file.set("Width", ut.width); t.file.set("Height", ut.height); + t.file.set("Confidence", ut.confidence); } t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */); } else { @@ -300,6 +301,7 @@ class utGallery : public BinaryGallery int32_t x = 0, y = 0; uint32_t width = 0, height = 0; + float confidence = 0; QByteArray header; if ((algorithmID <= -1) && (algorithmID >= -3)) { const QRectF frontalFace = t.file.get("FrontalFace"); @@ -324,6 +326,7 @@ class utGallery : public BinaryGallery y = t.file.get("Y", 0); width = t.file.get("Width", 0); height = t.file.get("Height", 0); + confidence = t.file.get("Confidence", 0); } gallery.write((const char*) &algorithmID, sizeof(int32_t)); @@ -331,6 +334,7 @@ class utGallery : public BinaryGallery gallery.write((const char*) &y , sizeof(int32_t)); gallery.write((const char*) &width , sizeof(uint32_t)); gallery.write((const char*) &height , sizeof(uint32_t)); + gallery.write((const char*) &confidence , sizeof(float)); const uint32_t mdSize = metadata.size() + 1; gallery.write((const char*) &mdSize, sizeof(uint32_t)); diff --git a/openbr/universal_template.cpp b/openbr/universal_template.cpp index d6bc0d4..4db21ae 100644 --- a/openbr/universal_template.cpp +++ b/openbr/universal_template.cpp @@ -8,7 +8,7 @@ #include "universal_template.h" -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) +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) { const uint32_t mdSize = strlen(metadata) + 1; 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_ utemplate->y = y; utemplate->width = width; utemplate->height = height; + utemplate->confidence = confidence; utemplate->mdSize = mdSize; utemplate->fvSize = fvSize; memcpy(reinterpret_cast(utemplate+1) + 0, metadata , mdSize); diff --git a/openbr/universal_template.h b/openbr/universal_template.h index a9264f3..3cdaa56 100644 --- a/openbr/universal_template.h +++ b/openbr/universal_template.h @@ -40,6 +40,7 @@ struct br_universal_template int32_t y; /*!< Region of interest vertical offset (pixels). */ uint32_t width; /*!< Region of interest horizontal size (pixels). */ uint32_t height; /*!< Region of interest vertical size (pixels). */ + float confidence; /*!< Region of interest confidence. */ uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_, including the null-terminator character itself. */ 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; * \brief br_universal_template constructor. * \see br_free_utemplate */ -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); +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); /*! * \brief br_universal_template destructor. -- libgit2 0.21.4