Commit 5fa517299619099fc091df9995f1c82a4bbd9e36
1 parent
57118ef4
Fix utGallery::writeTemplate missing metadata key error when input is also utGallery
Showing
1 changed file
with
23 additions
and
5 deletions
openbr/plugins/gallery.cpp
| ... | ... | @@ -248,12 +248,30 @@ class utGallery : public BinaryGallery |
| 248 | 248 | t.file.set("ImageID", QVariant(QByteArray((const char*)ut.imageID, 16).toHex())); |
| 249 | 249 | t.file.set("TemplateID", QVariant(QByteArray((const char*)ut.templateID, 16).toHex())); |
| 250 | 250 | t.file.set("AlgorithmID", ut.algorithmID); |
| 251 | - t.file.set("X", ut.x); | |
| 252 | - t.file.set("Y", ut.y); | |
| 253 | - t.file.set("Width", ut.width); | |
| 254 | - t.file.set("Height", ut.height); | |
| 255 | 251 | t.file.set("URL", QString(data.data())); |
| 256 | - t.append(cv::Mat(1, ut.size - ut.urlSize, CV_8UC1, data.data() + ut.urlSize).clone() /* We don't want a shallow copy! */); | |
| 252 | + char *dataStart = data.data() + ut.urlSize; | |
| 253 | + uint32_t dataSize = ut.size - ut.urlSize; | |
| 254 | + if (ut.algorithmID == -1) { | |
| 255 | + t.file.set("FrontalFace", QRectF(ut.x, ut.y, ut.width, ut.height)); | |
| 256 | + uint32_t *rightEyeX = reinterpret_cast<uint32_t*>(dataStart); | |
| 257 | + dataStart += sizeof(uint32_t); | |
| 258 | + uint32_t *rightEyeY = reinterpret_cast<uint32_t*>(dataStart); | |
| 259 | + dataStart += sizeof(uint32_t); | |
| 260 | + uint32_t *leftEyeX = reinterpret_cast<uint32_t*>(dataStart); | |
| 261 | + dataStart += sizeof(uint32_t); | |
| 262 | + uint32_t *leftEyeY = reinterpret_cast<uint32_t*>(dataStart); | |
| 263 | + dataStart += sizeof(uint32_t); | |
| 264 | + dataSize -= sizeof(uint32_t)*4; | |
| 265 | + t.file.set("First_Eye", QPointF(*rightEyeX, *rightEyeY)); | |
| 266 | + t.file.set("Second_Eye", QPointF(*leftEyeX, *leftEyeY)); | |
| 267 | + } | |
| 268 | + else { | |
| 269 | + t.file.set("X", ut.x); | |
| 270 | + t.file.set("Y", ut.y); | |
| 271 | + t.file.set("Width", ut.width); | |
| 272 | + t.file.set("Height", ut.height); | |
| 273 | + } | |
| 274 | + t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */); | |
| 257 | 275 | } else { |
| 258 | 276 | if (!gallery.atEnd()) |
| 259 | 277 | qFatal("Failed to read universal template header!"); | ... | ... |