From 4896059836486e7b8e85613e0eef838933b6446c Mon Sep 17 00:00:00 2001 From: caotto Date: Tue, 22 Jan 2013 13:46:22 -0500 Subject: [PATCH] Handle facevacs config file location --- sdk/openbr_plugin.cpp | 6 ++---- sdk/plugins/ct8.cmake | 1 + sdk/plugins/ct8.cpp | 33 +++++++++++++++++++++++++-------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/sdk/openbr_plugin.cpp b/sdk/openbr_plugin.cpp index 3e0f31a..5ea5f33 100644 --- a/sdk/openbr_plugin.cpp +++ b/sdk/openbr_plugin.cpp @@ -581,7 +581,7 @@ void Object::setProperty(const QString &name, const QString &value) QString type; int index = metaObject()->indexOfProperty(qPrintable(name)); if (index != -1) type = metaObject()->property(index).typeName(); - else return; + else type = ""; QVariant variant; if (type.startsWith("QList<") && type.endsWith(">")) { @@ -619,9 +619,7 @@ void Object::setProperty(const QString &name, const QString &value) variant = value; } - if (!QObject::setProperty(qPrintable(name), variant)) - qFatal("Failed to set %s::%s to: %s %s", - metaObject()->className(), qPrintable(name), qPrintable(value), qPrintable(type)); + QObject::setProperty(qPrintable(name), variant); } QStringList br::Object::parse(const QString &string, char split) diff --git a/sdk/plugins/ct8.cmake b/sdk/plugins/ct8.cmake index 4a5634e..d8ff6d1 100644 --- a/sdk/plugins/ct8.cmake +++ b/sdk/plugins/ct8.cmake @@ -12,4 +12,5 @@ if(${BR_WITH_CT8}) ${CT8_DIR_LIB}/../share/libiomp5.so DESTINATION lib) install(DIRECTORY ${CT8_DIR}/etc DESTINATION models/ct8) + add_definitions(-DCT8_DIR=\"${CT8_DIR}\") endif() diff --git a/sdk/plugins/ct8.cpp b/sdk/plugins/ct8.cpp index 22e16fe..b3cc021 100644 --- a/sdk/plugins/ct8.cpp +++ b/sdk/plugins/ct8.cpp @@ -18,6 +18,8 @@ using namespace cv; using namespace br; +#define CT8_CONFIG_PROP "ct8ConfigFile" + namespace FRsdk { // Construct a FaceVACS sdk ImageBody from an opencv Mat struct OpenCVImageBody : public ImageBody @@ -135,18 +137,18 @@ namespace FRsdk { }; } - struct CT8Initialize : public Initializer { static FRsdk::Configuration* CT8Configuration; - +public: // ct8 plugin initialization, load a FRsdk config file, and register // the shortcut for using FaceVACS feature extraction/comparison void initialize() const { try { - // Need to do something different wrt getting the config file location -cao - CT8Configuration = new FRsdk::Configuration("C:/FVSDK_8_6_0/etc/frsdk.cfg"); + QString store_string = QString((CT8_DIR + std::string("/etc/frsdk.cfg")).c_str()); + Globals->setProperty(CT8_CONFIG_PROP, store_string); + CT8Configuration = NULL; Globals->abbreviations.insert("CT8","Open+CT8Detect!CT8Enroll:CT8Compare"); } catch (std::exception &e) { qWarning("CT8Initialize Exception: %s", e.what()); @@ -154,6 +156,21 @@ struct CT8Initialize : public Initializer } } + static FRsdk::Configuration * getCT8Configuration() + { + if (!CT8Configuration) { + QVariant recovered_variant= Globals->property(CT8_CONFIG_PROP); + QString recovered_string = recovered_variant.toString(); + try { + CT8Configuration = new FRsdk::Configuration(qPrintable(recovered_string)); + } catch (std::exception &e) { + qFatal("CT8Initialize Exception: %s", e.what()); + } + } + return CT8Configuration; + } + + void finalize() const { delete CT8Configuration; @@ -183,10 +200,10 @@ struct CT8Context CT8Context() { try { - faceFinder = new FRsdk::Face::Finder(*CT8Initialize::CT8Configuration); - eyesFinder = new FRsdk::Eyes::Finder(*CT8Initialize::CT8Configuration); - firBuilder = new FRsdk::FIRBuilder(*CT8Initialize::CT8Configuration); - facialMatchingEngine = new FRsdk::FacialMatchingEngine(*CT8Initialize::CT8Configuration); + faceFinder = new FRsdk::Face::Finder(*CT8Initialize::getCT8Configuration()); + eyesFinder = new FRsdk::Eyes::Finder(*CT8Initialize::getCT8Configuration()); + firBuilder = new FRsdk::FIRBuilder(*CT8Initialize::getCT8Configuration()); + facialMatchingEngine = new FRsdk::FacialMatchingEngine(*CT8Initialize::getCT8Configuration()); } catch (std::exception &e) { qFatal("CT8Context Exception: %s", e.what()); } -- libgit2 0.21.4