forked from skaringa/emeocv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfig.cpp
58 lines (51 loc) · 2.28 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
56
57
/*
* Config.cpp
*
*/
#include <opencv2/highgui/highgui.hpp>
#include "Config.h"
Config::Config() :
_rotationDegrees(0), _digitCount(7), _ocrMaxDist(2100000), _digitYAlignment(20), _cannyThreshold1(160), _cannyThreshold2(
255), _trainingDataFilename("trainctr.yml"), _cliCaptureTemporaryPath("/dev/shm/image_emeocv.png"), _cliCaptureCommand("raspistill -w 800 -h 600 -n -o"), _counterMarkerHLOW(30), _counterMarkerHHI(85), _counterMarkerSLOW(35), _counterMarkerVLOW(80), _maxImageHeight(600) {
}
void Config::saveConfig() {
cv::FileStorage fs("config.yml", cv::FileStorage::WRITE);
fs << "rotationDegrees" << _rotationDegrees;
fs << "cannyThreshold1" << _cannyThreshold1;
fs << "cannyThreshold2" << _cannyThreshold2;
fs << "digitYAlignment" << _digitYAlignment;
fs << "ocrMaxDist" << _ocrMaxDist;
fs << "trainingDataFilename" << _trainingDataFilename;
fs << "cliCaptureCommand" << _cliCaptureCommand;
fs << "cliCaptureTemporaryPath" << _cliCaptureTemporaryPath;
fs << "counterMarkerHLOW" << _counterMarkerHLOW;
fs << "counterMarkerHHI" << _counterMarkerHHI;
fs << "counterMarkerSLOW" << _counterMarkerSLOW;
fs << "counterMarkerVLOW" << _counterMarkerVLOW;
fs << "maxImageHeight" << _maxImageHeight;
fs << "digitCount" << _digitCount;
fs.release();
}
void Config::loadConfig() {
cv::FileStorage fs("config.yml", cv::FileStorage::READ);
if (fs.isOpened()) {
fs["rotationDegrees"] >> _rotationDegrees;
fs["cannyThreshold1"] >> _cannyThreshold1;
fs["cannyThreshold2"] >> _cannyThreshold2;
fs["digitYAlignment"] >> _digitYAlignment;
fs["ocrMaxDist"] >> _ocrMaxDist;
fs["trainingDataFilename"] >> _trainingDataFilename;
fs["cliCaptureCommand"] >> _cliCaptureCommand;
fs["cliCaptureTemporaryPath"] >> _cliCaptureTemporaryPath;
fs["counterMarkerHLOW"] >> _counterMarkerHLOW;
fs["counterMarkerHHI"] >> _counterMarkerHHI;
fs["counterMarkerSLOW"] >> _counterMarkerSLOW;
fs["counterMarkerVLOW"] >> _counterMarkerVLOW;
fs["maxImageHeight"] >> _maxImageHeight;
fs["digitCount"] >> _digitCount;
fs.release();
} else {
// no config file - create an initial one with default values
saveConfig();
}
}