diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 6eba193..2069395 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -184,7 +184,7 @@ struct AlgorithmCore return fileList; } - void enroll(Template &data) + void enroll(TemplateList &data) { if (transform.isNull()) qFatal("Null transform."); data >> *transform; @@ -377,9 +377,10 @@ FileList br::Enroll(const File &input, const File &gallery) return AlgorithmManager::getAlgorithm(gallery.get("algorithm"))->enroll(input, gallery); } -void br::Enroll(Template &tmpl) +void br::Enroll(TemplateList &tl) { - AlgorithmManager::getAlgorithm(tmpl.file.get("algorithm"))->enroll(tmpl); + QString alg = tl.first().file.get("algorithm"); + AlgorithmManager::getAlgorithm(alg)->enroll(tl); } void br::Compare(const File &targetGallery, const File &queryGallery, const File &output) diff --git a/openbr/openbr.cpp b/openbr/openbr.cpp index 41c16db..e8b6bf6 100644 --- a/openbr/openbr.cpp +++ b/openbr/openbr.cpp @@ -331,8 +331,17 @@ int br_img_channels(br_template tmpl) return t->m().channels(); } -void br_enroll_template(br_template tmpl) +br_template_list br_enroll_template(br_template tmpl) { Template *t = reinterpret_cast(tmpl); - Enroll(*t); + TemplateList *tl = new TemplateList(); + tl->append(*t); + Enroll(*tl); + return (br_template_list)tl; +} + +br_template br_get_template(br_template_list tl, int index) +{ + TemplateList *realTL = reinterpret_cast(tl); + return (br_template)&realTL->at(index); } diff --git a/openbr/openbr.h b/openbr/openbr.h index 2690d0b..355f7c0 100644 --- a/openbr/openbr.h +++ b/openbr/openbr.h @@ -420,10 +420,11 @@ BR_EXPORT const char *br_version(); BR_EXPORT void br_slave_process(const char * baseKey); // to avoid having to include unwanted headers -// this will be this header's conception of a template +// this will be this header's conception of a Template // any functions that need a Template pointer // will take this typedef and cast it typedef void* br_template; +typedef void* br_template_list; /*! * \brief Load an image from a string buffer. * 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); */ BR_EXPORT int br_img_channels(br_template tmpl); /*! - * \brief Enroll a br::Template from the C API! + * \brief Enroll a br::Template from the C API! Returns a br::TemplateList */ -BR_EXPORT void br_enroll_template(br_template tmpl); +BR_EXPORT br_template_list br_enroll_template(br_template tmpl); +BR_EXPORT br_template br_get_template(br_template_list tl, int index); /*! @}*/ diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 3ad907c..3b62676 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1321,7 +1321,7 @@ BR_EXPORT FileList Enroll(const File &input, const File &gallery = File()); * \brief High-level function for enrolling templates. * \see br_enroll */ -BR_EXPORT void Enroll(Template &tmpl); +BR_EXPORT void Enroll(TemplateList &tmpl); /*! * \brief High-level function for comparing galleries.