Commit eaeb35313d2d05a5f9723eb8309101d2798a1b29
1 parent
51f633f3
Fix some C API issues
Showing
4 changed files
with
13 additions
and
15 deletions
openbr/core/core.cpp
| ... | ... | @@ -160,7 +160,7 @@ struct AlgorithmCore |
| 160 | 160 | data.removeAt(i); |
| 161 | 161 | const int numFiles = data.size(); |
| 162 | 162 | |
| 163 | - enroll(data); | |
| 163 | + data >> *transform; | |
| 164 | 164 | |
| 165 | 165 | g->writeBlock(data); |
| 166 | 166 | const FileList newFiles = data.files(); |
| ... | ... | @@ -184,9 +184,10 @@ struct AlgorithmCore |
| 184 | 184 | return fileList; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - void enroll(TemplateList &data) | |
| 187 | + void enroll(Template &data) | |
| 188 | 188 | { |
| 189 | - data >> *transform; | |
| 189 | + if (transform.isNull()) qFatal("Null transform."); | |
| 190 | + data = (data >> *transform); | |
| 190 | 191 | } |
| 191 | 192 | |
| 192 | 193 | void retrieveOrEnroll(const File &file, QScopedPointer<Gallery> &gallery, FileList &galleryFiles) |
| ... | ... | @@ -376,12 +377,9 @@ FileList br::Enroll(const File &input, const File &gallery) |
| 376 | 377 | return AlgorithmManager::getAlgorithm(gallery.get<QString>("algorithm"))->enroll(input, gallery); |
| 377 | 378 | } |
| 378 | 379 | |
| 379 | -void br::Enroll(const Template &tmpl) | |
| 380 | +void br::Enroll(Template &tmpl) | |
| 380 | 381 | { |
| 381 | - QList<Template> tmpls; | |
| 382 | - tmpls.append(tmpl); | |
| 383 | - TemplateList tl(tmpls); | |
| 384 | - AlgorithmManager::getAlgorithm(tmpl.file.get<QString>("algorithm"))->enroll(tl); | |
| 382 | + AlgorithmManager::getAlgorithm(tmpl.file.get<QString>("algorithm"))->enroll(tmpl); | |
| 385 | 383 | } |
| 386 | 384 | |
| 387 | 385 | void br::Compare(const File &targetGallery, const File &queryGallery, const File &output) | ... | ... |
openbr/openbr.cpp
| ... | ... | @@ -308,26 +308,26 @@ br_template br_load_img(const char *data) |
| 308 | 308 | return (br_template)tmpl; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | -const unsigned char *br_unload_img(br_template tmpl) | |
| 311 | +unsigned char *br_unload_img(br_template tmpl) | |
| 312 | 312 | { |
| 313 | - Template *t = (Template*)tmpl; | |
| 313 | + Template *t = reinterpret_cast<Template*>(tmpl); | |
| 314 | 314 | return t->m().data; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | int br_img_rows(br_template tmpl) |
| 318 | 318 | { |
| 319 | - Template *t = (Template*)tmpl; | |
| 319 | + Template *t = reinterpret_cast<Template*>(tmpl); | |
| 320 | 320 | return t->m().rows; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | int br_img_cols(br_template tmpl) |
| 324 | 324 | { |
| 325 | - Template *t = (Template*)tmpl; | |
| 325 | + Template *t = reinterpret_cast<Template*>(tmpl); | |
| 326 | 326 | return t->m().cols; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | void br_enroll_template(br_template tmpl) |
| 330 | 330 | { |
| 331 | - Template *t = (Template*)tmpl; | |
| 331 | + Template *t = reinterpret_cast<Template*>(tmpl); | |
| 332 | 332 | Enroll(*t); |
| 333 | 333 | } | ... | ... |
openbr/openbr.h
| ... | ... | @@ -426,7 +426,7 @@ typedef void* br_template; |
| 426 | 426 | * Easy way to pass an image in memory from another programming language to openbr. |
| 427 | 427 | */ |
| 428 | 428 | BR_EXPORT br_template br_load_img(const char *data); |
| 429 | -BR_EXPORT const unsigned char* br_unload_img(br_template tmpl); | |
| 429 | +BR_EXPORT unsigned char* br_unload_img(br_template tmpl); | |
| 430 | 430 | BR_EXPORT int br_img_rows(br_template tmpl); |
| 431 | 431 | BR_EXPORT int br_img_cols(br_template tmpl); |
| 432 | 432 | BR_EXPORT void br_enroll_template(br_template tmpl); | ... | ... |
openbr/openbr_plugin.h
| ... | ... | @@ -1321,7 +1321,7 @@ BR_EXPORT FileList Enroll(const File &input, const File &gallery = File()); |
| 1321 | 1321 | * \brief High-level function for enrolling templates. |
| 1322 | 1322 | * \see br_enroll |
| 1323 | 1323 | */ |
| 1324 | -BR_EXPORT void Enroll(const Template &tmpl); | |
| 1324 | +BR_EXPORT void Enroll(Template &tmpl); | |
| 1325 | 1325 | |
| 1326 | 1326 | /*! |
| 1327 | 1327 | * \brief High-level function for comparing galleries. | ... | ... |