Commit 275afd267bd205cbc6c1dd6e1da1b321be24a7a1
1 parent
df6b3ee4
added new fields to br_universal_template to better support videos and clusterin…
…g/ground-truth assignment
Showing
3 changed files
with
12 additions
and
4 deletions
openbr/openbr_plugin.cpp
| @@ -439,14 +439,16 @@ br_utemplate Template::toUniversalTemplate(const Template &t) | @@ -439,14 +439,16 @@ br_utemplate Template::toUniversalTemplate(const Template &t) | ||
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | const int32_t algorithmID = findAndRemove<int32_t> (map, "AlgorithmID", 0); | 441 | const int32_t algorithmID = findAndRemove<int32_t> (map, "AlgorithmID", 0); |
| 442 | + const uint32_t frame = findAndRemove<uint32_t>(map, "Frame" , std::numeric_limits<uint32_t>::max()); | ||
| 442 | const int32_t x = findAndRemove<int32_t> (map, "X" , 0); | 443 | const int32_t x = findAndRemove<int32_t> (map, "X" , 0); |
| 443 | const int32_t y = findAndRemove<int32_t> (map, "Y" , 0); | 444 | const int32_t y = findAndRemove<int32_t> (map, "Y" , 0); |
| 444 | const uint32_t width = findAndRemove<uint32_t>(map, "Width" , 0); | 445 | const uint32_t width = findAndRemove<uint32_t>(map, "Width" , 0); |
| 445 | const uint32_t height = findAndRemove<uint32_t>(map, "Height" , 0); | 446 | const uint32_t height = findAndRemove<uint32_t>(map, "Height" , 0); |
| 446 | const float confidence = findAndRemove<float> (map, "Confidence" , 0); | 447 | const float confidence = findAndRemove<float> (map, "Confidence" , 0); |
| 448 | + const uint32_t personID = findAndRemove<uint32_t>(map, "PersonID" , std::numeric_limits<uint32_t>::max()); | ||
| 447 | const QByteArray metadata = QJsonDocument(QJsonObject::fromVariantMap(map)).toJson(); | 449 | const QByteArray metadata = QJsonDocument(QJsonObject::fromVariantMap(map)).toJson(); |
| 448 | const Mat &m = t; | 450 | const Mat &m = t; |
| 449 | - return br_new_utemplate(algorithmID, x, y, width, height, confidence, metadata.data(), (const char*) m.data, m.rows * m.cols * m.elemSize()); | 451 | + return br_new_utemplate(algorithmID, frame, x, y, width, height, confidence, personID, metadata.data(), (const char*) m.data, m.rows * m.cols * m.elemSize()); |
| 450 | } | 452 | } |
| 451 | 453 | ||
| 452 | Template Template::fromUniversalTemplate(br_const_utemplate ut) | 454 | Template Template::fromUniversalTemplate(br_const_utemplate ut) |
| @@ -497,11 +499,13 @@ Template Template::fromUniversalTemplate(br_const_utemplate ut) | @@ -497,11 +499,13 @@ Template Template::fromUniversalTemplate(br_const_utemplate ut) | ||
| 497 | } | 499 | } |
| 498 | 500 | ||
| 499 | map.insert("AlgorithmID", ut->algorithmID); | 501 | map.insert("AlgorithmID", ut->algorithmID); |
| 502 | + map.insert("Frame" , ut->frame ); | ||
| 500 | map.insert("X" , ut->x ); | 503 | map.insert("X" , ut->x ); |
| 501 | map.insert("Y" , ut->y ); | 504 | map.insert("Y" , ut->y ); |
| 502 | map.insert("Width" , ut->width ); | 505 | map.insert("Width" , ut->width ); |
| 503 | map.insert("Height" , ut->height ); | 506 | map.insert("Height" , ut->height ); |
| 504 | map.insert("Confidence" , ut->confidence ); | 507 | map.insert("Confidence" , ut->confidence ); |
| 508 | + map.insert("PersonID" , ut->personID ); | ||
| 505 | const Mat m = Mat(1, ut->fvSize, CV_8UC1, (void*)(ut->data + ut->mdSize)).clone(); | 509 | const Mat m = Mat(1, ut->fvSize, CV_8UC1, (void*)(ut->data + ut->mdSize)).clone(); |
| 506 | return Template(File(map), m); | 510 | return Template(File(map), m); |
| 507 | } | 511 | } |
openbr/universal_template.cpp
| @@ -8,19 +8,21 @@ | @@ -8,19 +8,21 @@ | ||
| 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, float confidence, const char *metadata, const char *featureVector, uint32_t fvSize) | 11 | +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) |
| 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); |
| 15 | utemplate->algorithmID = algorithmID; | 15 | utemplate->algorithmID = algorithmID; |
| 16 | + utemplate->frame = frame; | ||
| 16 | utemplate->x = x; | 17 | utemplate->x = x; |
| 17 | utemplate->y = y; | 18 | utemplate->y = y; |
| 18 | utemplate->width = width; | 19 | utemplate->width = width; |
| 19 | utemplate->height = height; | 20 | utemplate->height = height; |
| 20 | utemplate->confidence = confidence; | 21 | utemplate->confidence = confidence; |
| 22 | + utemplate->personID = personID; | ||
| 21 | utemplate->mdSize = mdSize; | 23 | utemplate->mdSize = mdSize; |
| 22 | utemplate->fvSize = fvSize; | 24 | utemplate->fvSize = fvSize; |
| 23 | - memcpy(reinterpret_cast<char*>(utemplate+1) + 0, metadata , mdSize); | 25 | + memcpy(reinterpret_cast<char*>(utemplate+1) + 0, metadata , mdSize); |
| 24 | memcpy(reinterpret_cast<char*>(utemplate+1) + mdSize, featureVector, fvSize); | 26 | memcpy(reinterpret_cast<char*>(utemplate+1) + mdSize, featureVector, fvSize); |
| 25 | return utemplate; | 27 | return utemplate; |
| 26 | } | 28 | } |
openbr/universal_template.h
| @@ -36,11 +36,13 @@ extern "C" { | @@ -36,11 +36,13 @@ extern "C" { | ||
| 36 | struct br_universal_template | 36 | struct br_universal_template |
| 37 | { | 37 | { |
| 38 | int32_t algorithmID; /*!< Interpretation of _data_ after _mdSize_. */ | 38 | int32_t algorithmID; /*!< Interpretation of _data_ after _mdSize_. */ |
| 39 | + uint32_t frame; /*!< Video frame number, or <tt>numeric_limits<uint32_t>::max()</tt> for still images. */ | ||
| 39 | int32_t x; /*!< Region of interest horizontal offset (pixels). */ | 40 | int32_t x; /*!< Region of interest horizontal offset (pixels). */ |
| 40 | int32_t y; /*!< Region of interest vertical offset (pixels). */ | 41 | int32_t y; /*!< Region of interest vertical offset (pixels). */ |
| 41 | uint32_t width; /*!< Region of interest horizontal size (pixels). */ | 42 | uint32_t width; /*!< Region of interest horizontal size (pixels). */ |
| 42 | uint32_t height; /*!< Region of interest vertical size (pixels). */ | 43 | uint32_t height; /*!< Region of interest vertical size (pixels). */ |
| 43 | float confidence; /*!< Region of interest confidence. */ | 44 | float confidence; /*!< Region of interest confidence. */ |
| 45 | + uint32_t personID; /*!< Unique identifier or <tt>numeric_limits<uint32_t>::max()</tt> if unknown. */ | ||
| 44 | uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_, | 46 | uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_, |
| 45 | including the null-terminator character itself. */ | 47 | including the null-terminator character itself. */ |
| 46 | uint32_t fvSize; /*!< Length of the feature vector after the metadata in _data_. */ | 48 | 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; | @@ -56,7 +58,7 @@ typedef const struct br_universal_template *br_const_utemplate; | ||
| 56 | * \brief br_universal_template constructor. | 58 | * \brief br_universal_template constructor. |
| 57 | * \see br_free_utemplate | 59 | * \see br_free_utemplate |
| 58 | */ | 60 | */ |
| 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); | 61 | +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); |
| 60 | 62 | ||
| 61 | /*! | 63 | /*! |
| 62 | * \brief br_universal_template destructor. | 64 | * \brief br_universal_template destructor. |