-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.cpp
55 lines (49 loc) · 1.7 KB
/
config.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "config.hpp"
Config::Config() {
this->loadProperties();
if (!this->loadSucceed) {
this->logFp.open("/data/facepam/facepam.log", ios::out);
this->logFp << "Load properties failed! Using defaults..." << endl;
this->facePath = "/data/facepam/faces/";
this->logPath = "/data/facepam/facepam.log";
this->confidenceGate = 0.6;
}
this->initModelPaths();
}
Config::~Config() {
this->logFp.close();
}
void Config::initModelPaths() {
this->faceDetectorModel = this->modelPath;
this->faceDetectorModel.append("/face_detector.seta");
this->faceLandmarkerModel = this->modelPath;
this->faceLandmarkerModel.append("/face_landmarker_pts5.csta");
this->faceRecognizerModel = this->modelPath;
this->faceRecognizerModel.append("/face_recognizer.csta");
}
void Config::loadProperties() {
try {
ptree ptr, tag;
ini_parser::read_ini("/etc/facepam.conf", ptr);
tag = ptr.get_child("General");
this->modelPath = tag.get<string>("ModelsPath");
this->facePath = tag.get<string>("FacesPath");
this->logPath = tag.get<string>("LogFile");
this->confidenceGate = tag.get<float>("ConfidenceGate");
this->loadSucceed = true;
this->logFp.open(this->logPath, ios::out);
} catch (exception e) {
this->loadSucceed = false;
cout << e.what() << endl;
}
}
void Config::writeToLog(const string message) {
this->logFp << message << endl;
}
vector<string> Config::getModelPaths() {
vector<string> result;
result.push_back(this->faceDetectorModel);
result.push_back(this->faceLandmarkerModel);
result.push_back(this->faceRecognizerModel);
return result;
}