diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 7fdaf59..677fc81 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -161,15 +161,13 @@ struct AlgorithmCore return name + file.baseName() + file.hash() + ".mem"; } - FileList enroll(File input, File gallery = File()) + void enroll(File input, File gallery = File()) { - FileList files; - qDebug("Enrolling %s%s", qPrintable(input.flat()), gallery.isNull() ? "" : qPrintable(" to " + gallery.flat())); if (gallery.name.isEmpty()) { - if (input.name.isEmpty()) return FileList(); + if (input.name.isEmpty()) return; else gallery = getMemoryGallery(input); } @@ -212,12 +210,8 @@ struct AlgorithmCore progressCounter->setPropertyRecursive("totalProgress", QString::number(total)); stream->projectUpdate(data, output); - files.append(output.files()); - if (multiProcess) delete enroll; - - return files; } void project(File input, File output) @@ -632,9 +626,9 @@ void br::Train(const File &input, const File &model) AlgorithmManager::getAlgorithm(model.get("algorithm"))->train(input, model); } -FileList br::Enroll(const File &input, const File &gallery) +void br::Enroll(const File &input, const File &gallery) { - return AlgorithmManager::getAlgorithm(gallery.get("algorithm"))->enroll(input, gallery); + AlgorithmManager::getAlgorithm(gallery.get("algorithm"))->enroll(input, gallery); } void br::Project(const File &input, const File &output) diff --git a/openbr/gui/classifier.cpp b/openbr/gui/classifier.cpp index 8fcfe8b..6e72c59 100644 --- a/openbr/gui/classifier.cpp +++ b/openbr/gui/classifier.cpp @@ -37,7 +37,13 @@ void Classifier::setClassification(const QString &key, const QString &value) void Classifier::_classify(File file) { QString key, value; - foreach (const File &f, Enroll(file.flat(), File("[algorithm=" + algorithm + "]"))) { + QSharedPointer transform = Transform::fromAlgorithm(algorithm); + + TemplateList input, output; + input.append(file); + transform->projectUpdate(input, output); + + foreach (const File &f, output.files() ) { if (algorithm == "GenderClassification") key = "Gender"; else if (algorithm == "AgeRegression") key = "Age"; else key = algorithm; diff --git a/openbr/gui/gallerytoolbar.cpp b/openbr/gui/gallerytoolbar.cpp index 673e60f..2dc574e 100644 --- a/openbr/gui/gallerytoolbar.cpp +++ b/openbr/gui/gallerytoolbar.cpp @@ -83,9 +83,10 @@ void br::GalleryToolBar::_enroll(const br::File &input) { galleryLock.lock(); this->input = input; - if (input.suffix() == "gal") gallery = input.name + ".mem"; - else gallery = QString("%1/galleries/%2.gal[cache]").arg(br::Globals->scratchPath(), qPrintable(input.baseName()+input.hash())); - files = br::Enroll(input.flat(), gallery.flat()); + gallery = input.name + ".mem"; + br::Enroll(input.flat(), gallery.flat()); + files = FileList::fromGallery(gallery); + galleryLock.unlock(); } diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index a329910..7b2b891 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1393,7 +1393,7 @@ BR_EXPORT void Train(const File &input, const File &model); * \brief High-level function for creating galleries. * \see br_enroll */ -BR_EXPORT FileList Enroll(const File &input, const File &gallery = File()); +BR_EXPORT void Enroll(const File &input, const File &gallery = File()); /*! * \brief High-level function for enrolling templates.