forked from kimphg/FireDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cpp
107 lines (92 loc) · 4.01 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "Config.h"
#include "qdir.h"
CConfig::CConfig()
{
LoadXmlFile();
}
void CConfig::LoadXmlFile()
{
if (!QDir(CONF_PATH).exists())
QDir().mkdir(CONF_PATH);
CvFileStorage* fs = NULL;
try
{
fs = cvOpenFileStorage(XML_FILE, 0, CV_STORAGE_READ);
}
catch (...)
{
setDefault();
return;
}
if (fs == NULL)
{
setDefault();
return;
}
//_config.strCamUrl = cvReadStringByName(fs, 0, "CamUrl", "rtsp://192.168.0.253:554/stream1"); // for K9-Camera: "rtsp://service:[email protected]:554/"
_config.strCamUrl = cvReadStringByName(fs, 0, "CamUrl", "rtsp://service:[email protected]:554/");
_config.strCamUrl2 = cvReadStringByName(fs, 0, "CamUrl2", "rtsp://service:[email protected]:554/");
_config.strCamUrl3 = cvReadStringByName(fs, 0, "CamUrl3", "rtsp://service:[email protected]:554/");
_config.frmPosX = cvReadIntByName(fs, 0, "FrmPosX", 0);
_config.frmPosY = cvReadIntByName(fs, 0, "FrmPosY", 0);
_config.frmWidth = cvReadIntByName(fs, 0, "FrmWidth", 600);
_config.frmHeight = cvReadIntByName(fs, 0, "FrmHeight", 500);
_config.smallArea = cvReadIntByName(fs, 0, "SmallArea", 200);
_config.largeArea = cvReadIntByName(fs, 0, "LargeArea", 4900);
_config.keepCount = cvReadIntByName(fs, 0, "KeepCount", 2);
_config.movDetect = cvReadRealByName(fs, 0, "MovDetect", -1);
_config.brightThreshold = cvReadIntByName(fs, 0, "BrightThreshold", 235);
_config.cropX = cvReadIntByName(fs, 0, "CropX", 50);
_config.cropY = cvReadIntByName(fs, 0, "CropY", 35);
_config.alarmNumber = cvReadIntByName(fs, 0, "AlarmNumber", 1);
_config.diffInOut = cvReadIntByName(fs, 0, "DiffInOut", 60);
_config.alarmLevel = cvReadIntByName(fs, 0, "AlarmLevel", 2);
_config.threshDetect = cvReadIntByName(fs, 0, "ThreshDetect", 20);
cvReleaseFileStorage(&fs);
}
void CConfig::setDefault()
{
//_config.strCamUrl = "rtsp://192.168.0.253:554/stream1"; // for K9-Camera: "rtsp://service:[email protected]:554/"
_config.strCamUrl = "rtsp://service:[email protected]:554/";
_config.strCamUrl2 = "rtsp://service:[email protected]:554/";
_config.strCamUrl3 = "rtsp://service:[email protected]:554/";
_config.frmPosX = 0;
_config.frmPosY = 0;
_config.frmWidth = 600;
_config.frmHeight = 500;
_config.smallArea = 200;
_config.largeArea = 4900;
_config.keepCount = 2;
_config.movDetect = -1;
_config.brightThreshold = 235;
_config.cropX = 50;
_config.cropY = 35;
_config.alarmNumber = 1;
_config.diffInOut = 60;
_config.alarmLevel = 2;
_config.threshDetect = 20;
SaveXmlFile();
}
void CConfig::SaveXmlFile()
{
CvFileStorage* fs = cvOpenFileStorage(XML_FILE, 0, CV_STORAGE_WRITE);
cvWriteString(fs, "CamUrl", _config.strCamUrl.data());
cvWriteString(fs, "CamUrl2", _config.strCamUrl2.data());
cvWriteString(fs, "CamUrl3", _config.strCamUrl3.data());
cvWriteInt(fs, "FrmPosX", _config.frmPosX);
cvWriteInt(fs, "FrmPosY", _config.frmPosY);
cvWriteInt(fs, "FrmWidth", _config.frmWidth);
cvWriteInt(fs, "FrmHeight", _config.frmHeight);
cvWriteInt(fs, "SmallArea", _config.smallArea);
cvWriteInt(fs, "LargeArea", _config.largeArea);
cvWriteInt(fs, "KeepCount", _config.keepCount);
cvWriteReal(fs, "MovDetect", _config.movDetect);
cvWriteInt(fs, "BrightThreshold", _config.brightThreshold);
cvWriteInt(fs, "CropX", _config.cropX);
cvWriteInt(fs, "CropY", _config.cropY);
cvWriteInt(fs, "AlarmNumber", _config.alarmNumber);
cvWriteInt(fs, "DiffInOut", _config.diffInOut);
cvWriteInt(fs, "AlarmLevel", _config.alarmLevel);
cvWriteInt(fs, "ThreshDetect", _config.threshDetect);
cvReleaseFileStorage(&fs);
}