diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index f1f374e..3979b36 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -439,14 +439,16 @@ br_utemplate Template::toUniversalTemplate(const Template &t) } const int32_t algorithmID = findAndRemove (map, "AlgorithmID", 0); + const uint32_t frame = findAndRemove(map, "Frame" , std::numeric_limits::max()); const int32_t x = findAndRemove (map, "X" , 0); const int32_t y = findAndRemove (map, "Y" , 0); const uint32_t width = findAndRemove(map, "Width" , 0); const uint32_t height = findAndRemove(map, "Height" , 0); const float confidence = findAndRemove (map, "Confidence" , 0); + const uint32_t personID = findAndRemove(map, "PersonID" , std::numeric_limits::max()); const QByteArray metadata = QJsonDocument(QJsonObject::fromVariantMap(map)).toJson(); const Mat &m = t; - return br_new_utemplate(algorithmID, x, y, width, height, confidence, metadata.data(), (const char*) m.data, m.rows * m.cols * m.elemSize()); + return br_new_utemplate(algorithmID, frame, x, y, width, height, confidence, personID, metadata.data(), (const char*) m.data, m.rows * m.cols * m.elemSize()); } Template Template::fromUniversalTemplate(br_const_utemplate ut) @@ -497,11 +499,13 @@ Template Template::fromUniversalTemplate(br_const_utemplate ut) } map.insert("AlgorithmID", ut->algorithmID); + map.insert("Frame" , ut->frame ); map.insert("X" , ut->x ); map.insert("Y" , ut->y ); map.insert("Width" , ut->width ); map.insert("Height" , ut->height ); map.insert("Confidence" , ut->confidence ); + map.insert("PersonID" , ut->personID ); const Mat m = Mat(1, ut->fvSize, CV_8UC1, (void*)(ut->data + ut->mdSize)).clone(); return Template(File(map), m); } diff --git a/openbr/universal_template.cpp b/openbr/universal_template.cpp index 4db21ae..5959465 100644 --- a/openbr/universal_template.cpp +++ b/openbr/universal_template.cpp @@ -8,19 +8,21 @@ #include "universal_template.h" -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) +br_utemplate br_new_utemplate(int32_t algorithmID, uint32_t frame, int32_t x, int32_t y, uint32_t width, uint32_t height, float confidence, uint32_t personID, 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); utemplate->algorithmID = algorithmID; + utemplate->frame = frame; utemplate->x = x; utemplate->y = y; utemplate->width = width; utemplate->height = height; utemplate->confidence = confidence; + utemplate->personID = personID; utemplate->mdSize = mdSize; utemplate->fvSize = fvSize; - memcpy(reinterpret_cast(utemplate+1) + 0, metadata , mdSize); + memcpy(reinterpret_cast(utemplate+1) + 0, metadata , mdSize); memcpy(reinterpret_cast(utemplate+1) + mdSize, featureVector, fvSize); return utemplate; } diff --git a/openbr/universal_template.h b/openbr/universal_template.h index 3cdaa56..026f868 100644 --- a/openbr/universal_template.h +++ b/openbr/universal_template.h @@ -36,11 +36,13 @@ extern "C" { struct br_universal_template { int32_t algorithmID; /*!< Interpretation of _data_ after _mdSize_. */ + uint32_t frame; /*!< Video frame number, or numeric_limits::max() for still images. */ int32_t x; /*!< Region of interest horizontal offset (pixels). */ 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 personID; /*!< Unique identifier or numeric_limits::max() if unknown. */ 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_. */ @@ -56,7 +58,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, float confidence, const char *metadata, const char *featureVector, uint32_t fvSize); +BR_EXPORT br_utemplate br_new_utemplate(int32_t algorithmID, uint32_t frame, int32_t x, int32_t y, uint32_t width, uint32_t height, float confidence, uint32_t personID, const char *metadata, const char *featureVector, uint32_t fvSize); /*! * \brief br_universal_template destructor.