Commit e20f7ec7ff2613c35cac3ebab833375e8e9a22e3
1 parent
8071e059
br-enroll and br-search now support template metadata
Showing
2 changed files
with
38 additions
and
3 deletions
app/br-enroll/br-enroll.cpp
| ... | ... | @@ -52,9 +52,31 @@ static void enroll_utemplate(br_const_utemplate utemplate, br_callback_context) |
| 52 | 52 | |
| 53 | 53 | foreach (const Template &t, templates) { |
| 54 | 54 | const Mat &m = t.m(); |
| 55 | - const uint32_t size = m.rows * m.cols * m.elemSize(); | |
| 56 | - const QByteArray templateID = QCryptographicHash::hash(QByteArray((const char*) m.data, size), QCryptographicHash::Md5); | |
| 57 | - br_append_utemplate_contents(stdout, utemplate->imageID, (const unsigned char*) templateID.data(), -1, size, m.data); | |
| 55 | + QByteArray data((const char*) m.data, m.rows * m.cols * m.elemSize()); | |
| 56 | + | |
| 57 | + const QRectF frontalFace = t.file.get<QRectF>("FrontalFace"); | |
| 58 | + const QPointF firstEye = t.file.get<QPointF>("First_Eye"); | |
| 59 | + const QPointF secondEye = t.file.get<QPointF>("Second_Eye"); | |
| 60 | + const float x = frontalFace.x(); | |
| 61 | + const float y = frontalFace.y(); | |
| 62 | + const float width = frontalFace.width(); | |
| 63 | + const float height = frontalFace.height(); | |
| 64 | + const float rightEyeX = firstEye.x(); | |
| 65 | + const float rightEyeY = firstEye.y(); | |
| 66 | + const float leftEyeX = secondEye.x(); | |
| 67 | + const float leftEyeY = secondEye.y(); | |
| 68 | + | |
| 69 | + data.append((const char*)&x , sizeof(float)); | |
| 70 | + data.append((const char*)&y , sizeof(float)); | |
| 71 | + data.append((const char*)&width , sizeof(float)); | |
| 72 | + data.append((const char*)&height , sizeof(float)); | |
| 73 | + data.append((const char*)&rightEyeX, sizeof(float)); | |
| 74 | + data.append((const char*)&rightEyeY, sizeof(float)); | |
| 75 | + data.append((const char*)&leftEyeX , sizeof(float)); | |
| 76 | + data.append((const char*)&leftEyeY , sizeof(float)); | |
| 77 | + | |
| 78 | + const QByteArray templateID = QCryptographicHash::hash(data, QCryptographicHash::Md5); | |
| 79 | + br_append_utemplate_contents(stdout, utemplate->imageID, (const unsigned char*) templateID.data(), -1, data.size(), (const unsigned char*) data.data()); | |
| 58 | 80 | } |
| 59 | 81 | } |
| 60 | 82 | ... | ... |
app/br-search/br-search.cpp
| ... | ... | @@ -131,6 +131,19 @@ struct FaceRecognition : public SearchResults |
| 131 | 131 | { |
| 132 | 132 | return algorithm->compare(target->data, query->data, 768); |
| 133 | 133 | } |
| 134 | + | |
| 135 | + void printMetadata(br_const_utemplate t) const | |
| 136 | + { | |
| 137 | + const float *metadata = reinterpret_cast<const float*>(&t->data[768]); | |
| 138 | + cout << ", \"X\":" << metadata[0] | |
| 139 | + << ", \"Y\":" << metadata[1] | |
| 140 | + << ", \"Width\":" << metadata[2] | |
| 141 | + << ", \"Height\":" << metadata[3] | |
| 142 | + << ", \"RightEyeX\":" << metadata[4] | |
| 143 | + << ", \"RightEyeY\":" << metadata[5] | |
| 144 | + << ", \"LeftEyeX\":" << metadata[6] | |
| 145 | + << ", \"LeftEyeY\":" << metadata[7]; | |
| 146 | + } | |
| 134 | 147 | }; |
| 135 | 148 | |
| 136 | 149 | struct MappedGallery | ... | ... |