Commit 9d5acfe2d50016ef9bd054a60da4f291ee39059d
1 parent
c5786a1a
Put template in a templatelist before enrolling, return the templatelist
Showing
4 changed files
with
21 additions
and
9 deletions
openbr/core/core.cpp
| ... | ... | @@ -184,7 +184,7 @@ struct AlgorithmCore |
| 184 | 184 | return fileList; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - void enroll(Template &data) | |
| 187 | + void enroll(TemplateList &data) | |
| 188 | 188 | { |
| 189 | 189 | if (transform.isNull()) qFatal("Null transform."); |
| 190 | 190 | data >> *transform; |
| ... | ... | @@ -377,9 +377,10 @@ FileList br::Enroll(const File &input, const File &gallery) |
| 377 | 377 | return AlgorithmManager::getAlgorithm(gallery.get<QString>("algorithm"))->enroll(input, gallery); |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | -void br::Enroll(Template &tmpl) | |
| 380 | +void br::Enroll(TemplateList &tl) | |
| 381 | 381 | { |
| 382 | - AlgorithmManager::getAlgorithm(tmpl.file.get<QString>("algorithm"))->enroll(tmpl); | |
| 382 | + QString alg = tl.first().file.get<QString>("algorithm"); | |
| 383 | + AlgorithmManager::getAlgorithm(alg)->enroll(tl); | |
| 383 | 384 | } |
| 384 | 385 | |
| 385 | 386 | void br::Compare(const File &targetGallery, const File &queryGallery, const File &output) | ... | ... |
openbr/openbr.cpp
| ... | ... | @@ -331,8 +331,17 @@ int br_img_channels(br_template tmpl) |
| 331 | 331 | return t->m().channels(); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | -void br_enroll_template(br_template tmpl) | |
| 334 | +br_template_list br_enroll_template(br_template tmpl) | |
| 335 | 335 | { |
| 336 | 336 | Template *t = reinterpret_cast<Template*>(tmpl); |
| 337 | - Enroll(*t); | |
| 337 | + TemplateList *tl = new TemplateList(); | |
| 338 | + tl->append(*t); | |
| 339 | + Enroll(*tl); | |
| 340 | + return (br_template_list)tl; | |
| 341 | +} | |
| 342 | + | |
| 343 | +br_template br_get_template(br_template_list tl, int index) | |
| 344 | +{ | |
| 345 | + TemplateList *realTL = reinterpret_cast<TemplateList*>(tl); | |
| 346 | + return (br_template)&realTL->at(index); | |
| 338 | 347 | } | ... | ... |
openbr/openbr.h
| ... | ... | @@ -420,10 +420,11 @@ BR_EXPORT const char *br_version(); |
| 420 | 420 | BR_EXPORT void br_slave_process(const char * baseKey); |
| 421 | 421 | |
| 422 | 422 | // to avoid having to include unwanted headers |
| 423 | -// this will be this header's conception of a template | |
| 423 | +// this will be this header's conception of a Template | |
| 424 | 424 | // any functions that need a Template pointer |
| 425 | 425 | // will take this typedef and cast it |
| 426 | 426 | typedef void* br_template; |
| 427 | +typedef void* br_template_list; | |
| 427 | 428 | /*! |
| 428 | 429 | * \brief Load an image from a string buffer. |
| 429 | 430 | * Easy way to pass an image in memory from another programming language to openbr. |
| ... | ... | @@ -450,9 +451,10 @@ BR_EXPORT int br_img_cols(br_template tmpl); |
| 450 | 451 | */ |
| 451 | 452 | BR_EXPORT int br_img_channels(br_template tmpl); |
| 452 | 453 | /*! |
| 453 | - * \brief Enroll a br::Template from the C API! | |
| 454 | + * \brief Enroll a br::Template from the C API! Returns a br::TemplateList | |
| 454 | 455 | */ |
| 455 | -BR_EXPORT void br_enroll_template(br_template tmpl); | |
| 456 | +BR_EXPORT br_template_list br_enroll_template(br_template tmpl); | |
| 457 | +BR_EXPORT br_template br_get_template(br_template_list tl, int index); | |
| 456 | 458 | |
| 457 | 459 | /*! @}*/ |
| 458 | 460 | ... | ... |
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(Template &tmpl); | |
| 1324 | +BR_EXPORT void Enroll(TemplateList &tmpl); | |
| 1325 | 1325 | |
| 1326 | 1326 | /*! |
| 1327 | 1327 | * \brief High-level function for comparing galleries. | ... | ... |