Commit 275afd267bd205cbc6c1dd6e1da1b321be24a7a1

Authored by Josh Klontz
1 parent df6b3ee4

added new fields to br_universal_template to better support videos and clusterin…

…g/ground-truth assignment
openbr/openbr_plugin.cpp
... ... @@ -439,14 +439,16 @@ br_utemplate Template::toUniversalTemplate(const Template &t)
439 439 }
440 440  
441 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 443 const int32_t x = findAndRemove<int32_t> (map, "X" , 0);
443 444 const int32_t y = findAndRemove<int32_t> (map, "Y" , 0);
444 445 const uint32_t width = findAndRemove<uint32_t>(map, "Width" , 0);
445 446 const uint32_t height = findAndRemove<uint32_t>(map, "Height" , 0);
446 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 449 const QByteArray metadata = QJsonDocument(QJsonObject::fromVariantMap(map)).toJson();
448 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 454 Template Template::fromUniversalTemplate(br_const_utemplate ut)
... ... @@ -497,11 +499,13 @@ Template Template::fromUniversalTemplate(br_const_utemplate ut)
497 499 }
498 500  
499 501 map.insert("AlgorithmID", ut->algorithmID);
  502 + map.insert("Frame" , ut->frame );
500 503 map.insert("X" , ut->x );
501 504 map.insert("Y" , ut->y );
502 505 map.insert("Width" , ut->width );
503 506 map.insert("Height" , ut->height );
504 507 map.insert("Confidence" , ut->confidence );
  508 + map.insert("PersonID" , ut->personID );
505 509 const Mat m = Mat(1, ut->fvSize, CV_8UC1, (void*)(ut->data + ut->mdSize)).clone();
506 510 return Template(File(map), m);
507 511 }
... ...
openbr/universal_template.cpp
... ... @@ -8,19 +8,21 @@
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, 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 13 const uint32_t mdSize = strlen(metadata) + 1;
14 14 br_utemplate utemplate = (br_utemplate) malloc(sizeof(br_universal_template) + mdSize + fvSize);
15 15 utemplate->algorithmID = algorithmID;
  16 + utemplate->frame = frame;
16 17 utemplate->x = x;
17 18 utemplate->y = y;
18 19 utemplate->width = width;
19 20 utemplate->height = height;
20 21 utemplate->confidence = confidence;
  22 + utemplate->personID = personID;
21 23 utemplate->mdSize = mdSize;
22 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 26 memcpy(reinterpret_cast<char*>(utemplate+1) + mdSize, featureVector, fvSize);
25 27 return utemplate;
26 28 }
... ...
openbr/universal_template.h
... ... @@ -36,11 +36,13 @@ extern &quot;C&quot; {
36 36 struct br_universal_template
37 37 {
38 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 40 int32_t x; /*!< Region of interest horizontal offset (pixels). */
40 41 int32_t y; /*!< Region of interest vertical offset (pixels). */
41 42 uint32_t width; /*!< Region of interest horizontal size (pixels). */
42 43 uint32_t height; /*!< Region of interest vertical size (pixels). */
43 44 float confidence; /*!< Region of interest confidence. */
  45 + uint32_t personID; /*!< Unique identifier or <tt>numeric_limits<uint32_t>::max()</tt> if unknown. */
44 46 uint32_t mdSize; /*!< Length of a null-terminated metadata string at the beginning of _data_,
45 47 including the null-terminator character itself. */
46 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 58 * \brief br_universal_template constructor.
57 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 64 * \brief br_universal_template destructor.
... ...