Commit 4896059836486e7b8e85613e0eef838933b6446c
1 parent
c8ab0035
Handle facevacs config file location
Export the facevacs directory found by cmake, use that to define a default config file location of facevacs_dir/etc/frsdk.cfg. Store the config file path as a property of Globals, allowing users to specify a config file path as a command line argument to br.exe. Modifications to openbr_plugin.cpp allow adding dynamic properties (strings only) to br::Objects.
Showing
3 changed files
with
28 additions
and
12 deletions
sdk/openbr_plugin.cpp
| ... | ... | @@ -581,7 +581,7 @@ void Object::setProperty(const QString &name, const QString &value) |
| 581 | 581 | QString type; |
| 582 | 582 | int index = metaObject()->indexOfProperty(qPrintable(name)); |
| 583 | 583 | if (index != -1) type = metaObject()->property(index).typeName(); |
| 584 | - else return; | |
| 584 | + else type = ""; | |
| 585 | 585 | |
| 586 | 586 | QVariant variant; |
| 587 | 587 | if (type.startsWith("QList<") && type.endsWith(">")) { |
| ... | ... | @@ -619,9 +619,7 @@ void Object::setProperty(const QString &name, const QString &value) |
| 619 | 619 | variant = value; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - if (!QObject::setProperty(qPrintable(name), variant)) | |
| 623 | - qFatal("Failed to set %s::%s to: %s %s", | |
| 624 | - metaObject()->className(), qPrintable(name), qPrintable(value), qPrintable(type)); | |
| 622 | + QObject::setProperty(qPrintable(name), variant); | |
| 625 | 623 | } |
| 626 | 624 | |
| 627 | 625 | QStringList br::Object::parse(const QString &string, char split) | ... | ... |
sdk/plugins/ct8.cmake
sdk/plugins/ct8.cpp
| ... | ... | @@ -18,6 +18,8 @@ |
| 18 | 18 | using namespace cv; |
| 19 | 19 | using namespace br; |
| 20 | 20 | |
| 21 | +#define CT8_CONFIG_PROP "ct8ConfigFile" | |
| 22 | + | |
| 21 | 23 | namespace FRsdk { |
| 22 | 24 | // Construct a FaceVACS sdk ImageBody from an opencv Mat |
| 23 | 25 | struct OpenCVImageBody : public ImageBody |
| ... | ... | @@ -135,18 +137,18 @@ namespace FRsdk { |
| 135 | 137 | }; |
| 136 | 138 | } |
| 137 | 139 | |
| 138 | - | |
| 139 | 140 | struct CT8Initialize : public Initializer |
| 140 | 141 | { |
| 141 | 142 | static FRsdk::Configuration* CT8Configuration; |
| 142 | - | |
| 143 | +public: | |
| 143 | 144 | // ct8 plugin initialization, load a FRsdk config file, and register |
| 144 | 145 | // the shortcut for using FaceVACS feature extraction/comparison |
| 145 | 146 | void initialize() const |
| 146 | 147 | { |
| 147 | 148 | try { |
| 148 | - // Need to do something different wrt getting the config file location -cao | |
| 149 | - CT8Configuration = new FRsdk::Configuration("C:/FVSDK_8_6_0/etc/frsdk.cfg"); | |
| 149 | + QString store_string = QString((CT8_DIR + std::string("/etc/frsdk.cfg")).c_str()); | |
| 150 | + Globals->setProperty(CT8_CONFIG_PROP, store_string); | |
| 151 | + CT8Configuration = NULL; | |
| 150 | 152 | Globals->abbreviations.insert("CT8","Open+CT8Detect!CT8Enroll:CT8Compare"); |
| 151 | 153 | } catch (std::exception &e) { |
| 152 | 154 | qWarning("CT8Initialize Exception: %s", e.what()); |
| ... | ... | @@ -154,6 +156,21 @@ struct CT8Initialize : public Initializer |
| 154 | 156 | } |
| 155 | 157 | } |
| 156 | 158 | |
| 159 | + static FRsdk::Configuration * getCT8Configuration() | |
| 160 | + { | |
| 161 | + if (!CT8Configuration) { | |
| 162 | + QVariant recovered_variant= Globals->property(CT8_CONFIG_PROP); | |
| 163 | + QString recovered_string = recovered_variant.toString(); | |
| 164 | + try { | |
| 165 | + CT8Configuration = new FRsdk::Configuration(qPrintable(recovered_string)); | |
| 166 | + } catch (std::exception &e) { | |
| 167 | + qFatal("CT8Initialize Exception: %s", e.what()); | |
| 168 | + } | |
| 169 | + } | |
| 170 | + return CT8Configuration; | |
| 171 | + } | |
| 172 | + | |
| 173 | + | |
| 157 | 174 | void finalize() const |
| 158 | 175 | { |
| 159 | 176 | delete CT8Configuration; |
| ... | ... | @@ -183,10 +200,10 @@ struct CT8Context |
| 183 | 200 | CT8Context() |
| 184 | 201 | { |
| 185 | 202 | try { |
| 186 | - faceFinder = new FRsdk::Face::Finder(*CT8Initialize::CT8Configuration); | |
| 187 | - eyesFinder = new FRsdk::Eyes::Finder(*CT8Initialize::CT8Configuration); | |
| 188 | - firBuilder = new FRsdk::FIRBuilder(*CT8Initialize::CT8Configuration); | |
| 189 | - facialMatchingEngine = new FRsdk::FacialMatchingEngine(*CT8Initialize::CT8Configuration); | |
| 203 | + faceFinder = new FRsdk::Face::Finder(*CT8Initialize::getCT8Configuration()); | |
| 204 | + eyesFinder = new FRsdk::Eyes::Finder(*CT8Initialize::getCT8Configuration()); | |
| 205 | + firBuilder = new FRsdk::FIRBuilder(*CT8Initialize::getCT8Configuration()); | |
| 206 | + facialMatchingEngine = new FRsdk::FacialMatchingEngine(*CT8Initialize::getCT8Configuration()); | |
| 190 | 207 | } catch (std::exception &e) { |
| 191 | 208 | qFatal("CT8Context Exception: %s", e.what()); |
| 192 | 209 | } | ... | ... |