diff --git a/openbr/CMakeLists.txt b/openbr/CMakeLists.txt index 8d2102c..8f82b9f 100644 --- a/openbr/CMakeLists.txt +++ b/openbr/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Janus API include_directories(janus/include) install(DIRECTORY janus/include DESTINATION .) -set(BR_JANUS janus/src/janus_io.cpp janus/src/opencv_io/opencv_io.cpp) +set(BR_JANUS janus/src/opencv_io/opencv_io.cpp) add_definitions(-DJANUS_LIBRARY) # Collect source files diff --git a/openbr/janus b/openbr/janus index 2ee03fd..6706011 160000 --- a/openbr/janus +++ b/openbr/janus @@ -1 +1 @@ -Subproject commit 2ee03fde082140e3a4210775cbbc2898e888e90a +Subproject commit 670601106366ca802289ca1916a47b6f2ed4976e diff --git a/openbr/janus_io.cpp b/openbr/janus_io.cpp new file mode 100644 index 0000000..a371bf8 --- /dev/null +++ b/openbr/janus_io.cpp @@ -0,0 +1,37 @@ +#include + +#define JANUS_CUSTOM_ADD_SAMPLE +#define JANUS_CUSTOM_CREATE_GALLERY +#include "janus/src/janus_io.cpp" + +static void _janus_add_sample(vector &samples, double sample) +{ + static QMutex sampleLock; + QMutexLocker sampleLocker(&sampleLock); + samples.push_back(sample); +} + +static void _janus_create_template(const char *data_path, TemplateData templateData, janus_gallery gallery) +{ + janus_template template_; + janus_template_id templateID; + JANUS_ASSERT(TemplateIterator::create(data_path, templateData, &template_, &templateID)) + + static QMutex enrollLock; + QMutexLocker enrollLocker(&enrollLock); + + JANUS_ASSERT(janus_enroll(template_, templateID, gallery)) +} + +janus_error janus_create_gallery(const char *data_path, janus_metadata metadata, janus_gallery gallery) +{ + TemplateIterator ti(metadata, true); + TemplateData templateData = ti.next(); + QFutureSynchronizer futures; + while (!templateData.templateIDs.empty()) { + futures.addFuture(QtConcurrent::run(_janus_create_template, data_path, templateData, gallery)); + templateData = ti.next(); + } + futures.waitForFinished(); + return JANUS_SUCCESS; +}