-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
241 lines (226 loc) · 7.63 KB
/
main.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#include "home.h"
LoggerPtr loggerConsole(Logger::getLogger( "Console"));
string videoPath;
void ClearScreen(){
HANDLE hStdOut;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD count;
DWORD cellCount;
COORD homeCoords = { 0, 0 };
hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
if (hStdOut == INVALID_HANDLE_VALUE) return;
/* Get the number of cells in the current buffer */
if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return;
cellCount = csbi.dwSize.X *csbi.dwSize.Y;
/* Fill the entire buffer with spaces */
if (!FillConsoleOutputCharacter(
hStdOut,
(TCHAR) ' ',
cellCount,
homeCoords,
&count
)) return;
/* Fill the entire buffer with the current colors and attributes */
if (!FillConsoleOutputAttribute(
hStdOut,
csbi.wAttributes,
cellCount,
homeCoords,
&count
)) return;
/* Move the cursor home */
SetConsoleCursorPosition( hStdOut, homeCoords );
}
void shodowThresholdMenu(){
//alfa deve essere compreso tra 0 e 1
do{
cout << "Define alfa con un valore compreso tra 0 e 1: (-1 to set AUTO)\n ";
cin >> initPar.alfa;
}while(initPar.alfa<-1 || initPar.alfa>1);
//beta deve essere compreso tra 0 e 1, inoltre deve essere maggiore di alfa
do {
cout << "Define beta con un valore compreso tra 0 e 1: (-1 to set AUTO)\n ";
cin >> initPar.beta;
}while (initPar.beta<-1 || initPar.beta>1 || initPar.alfa>initPar.beta);
cout << "Define Th: ";
cin >> initPar.Th;
cout << "Define Ts: ";
cin >> initPar.Ts;
//cout << "Define K: ";
//cin >> initPar.K;
}
int ParameterMenu(){
int res;
const char u = ' ';
istringstream tempI;
string temp;
while(TRUE){
ClearScreen();
cout << "Parameter Menu:";
cout << "\n1 - Thread number ("<< initPar.POOL <<")"<< endl;
cout << "2 - Number of processed frame for every single thread ("<< initPar.THREAD_NUM<<")"<< endl;
cout << "3 - Number of frame for background learning ("<< initPar.cicle_background<<")"<< endl;
cout << "4 - Delivery Service (enable/disable) ("<< initPar.thread_saving <<")" << endl;
cout << "5 - Background suppression threshold ("<< initPar.THRESHOLD<<")" << endl;
cout << "6 - Shadow threshold (alfa: "<< initPar.alfa<<", beta: "<<initPar.beta<<", Th: "<<initPar.Th<<", Ts: "<<initPar.Ts<<")" << endl;
cout << "7 - Set max concurrent thread ("<< initPar.wait <<")" << endl;
cout << "8 - Save in a three directories (enable/disable) ("<< initPar.three <<")" << endl;
cout << "9 - Save shadow (enable/disable) ("<< initPar.saveShadow<<")" << endl;
cout << "10 - Supervisioning (enable/disable) ("<< initPar.supervisioning <<")" << endl;
cout << "11 - Salient (enable/disable) ("<< initPar.fitting<<")" << endl;
cout << "12 - Area filtering parameter (minArea: "<< initPar.minArea<<", maxArea: "<<initPar.maxArea<<")" << endl;
cout << "0 - TERMINATED" << endl;
cout << "Input: ";
cin>>temp;
istringstream tempI(temp);
tempI>>res;
switch(res){
case 1:
cout << "\ndefine number of thread: ";
cin >> initPar.POOL;
break;
case 2:
cout << "max frame for thread : ";
cin >> initPar.THREAD_NUM;
break;
case 3:
cout << "number of training frame: ";
cin >> initPar.cicle_background;
break;
case 4:
if(initPar.thread_saving==TRUE){
initPar.thread_saving=FALSE;
cout << "Delivery enabled" << endl;
}else{
initPar.thread_saving=TRUE;
cout << "Delivery disabled" << endl;
}
system("PAUSE");
break;
case 5:
do{
cout << "background suppression threshold: ";
cin >> initPar.THRESHOLD;
}while(initPar.THRESHOLD>250 || initPar.THRESHOLD<-1);
break;
case 6:
shodowThresholdMenu();
break;
case 7:
cout << "max concurrent: ";
cin >> initPar.wait;
break;
case 8:
if(initPar.three==TRUE){
initPar.three=FALSE;
cout << "Three foldering disabled" << endl;
}else{
initPar.three=TRUE;
cout << "Three foldering enabled" << endl;
}
system("PAUSE");
break;
case 9:
if(initPar.saveShadow==TRUE){
initPar.saveShadow=FALSE;
cout << "Save shadow disabled" << endl;
}else{
initPar.saveShadow=TRUE;
cout << "Save shadow enabled" << endl;
}
system("PAUSE");
break;
case 10:
if(initPar.supervisioning==TRUE){
initPar.supervisioning=FALSE;
cout << "Supervisioning disabled" << endl;
}else{
initPar.supervisioning=TRUE;
cout << "Supervisioning enabled" << endl;
}
system("PAUSE");
break;
case 11:
if(initPar.fitting==FALSE){
cout << "Salient selection enabled" << endl;
cout << "Insert an area threashold. Number of fitting pixel: ";
cin>>initPar.fitting;
}else{
initPar.fitting=FALSE;
cout << "Salient selection disabled" << endl;
}
system("PAUSE");
break;
case 12:
cout << "Insert min area: ";
cin >> initPar.minArea;
cout << "Insert max area: ";
cin >> initPar.maxArea;
system("PAUSE");
break;
case 0:
return 0;
default:
cout << "Invalid option" << endl;
break;
}
}
}
int HomeMenu(){
string AUTO="auto";
int res=-1;
string temp;
ClearScreen();
cin.clear();
cout << "*******************************************************************************" << endl;
cout << "* MVO'S & SHADOW DETECTION console v.1.0 *" << endl;
cout << "* (Università degli studi di Catania - 2010-2011) *" << endl;
cout << "*-----------------------------------------------------------------------------*" << endl;
cout << "* ++ || Paolo Pino || ++ || Pierluigi Sottile || ++ || Vittorio Minacori|| ++ *" << endl;
cout << "*******************************************************************************" << endl;
cout << "\n -DEFAULT PARAMS-------------------------------------------------------------" << endl;
cout << "| background training: "<< initPar.cicle_background<<" frame | Delivery service off: "<< initPar.thread_saving<<" | gap = " << initPar.wait<< endl;
cout << "| Supervisioning: " << initPar.supervisioning<<endl;
cout << "| background threshold: " << initPar.THRESHOLD << " | Save shadow: " << initPar.saveShadow << " | Foldering enable: " << initPar.three<< endl;
cout << "| Delta: " << initPar.Delta << " | alfa: "<<initPar.alfa<<" | beta: "<<initPar.beta<<" | Th: "<<initPar.Th<<" | Ts: "<<initPar.Ts<<" \t "<<endl;
cout << " ------------------------------------------------------------------------------" << endl;
cout << "\n Stream: "<< videoPath << endl;
cout << "\n1 - START"<< endl;
cout << "2 - Set video path"<< endl;
cout << "3 - Change parameter" << endl;
cout << "0 - QUIT" << endl;
cout << "\nInput: ";
cin>>temp;
istringstream tempI(temp);
tempI>>res;
return res;
}
int main ( int argc, char **argv ){
string response = "";
videoPath = "c:/users/paolo/videos/last.avi";
DOMConfigurator::configure("Log4cxxConfig.xml");
initPar = initializationParams();
int res;
while(TRUE){
res=HomeMenu();
switch(res){
case 1:
Start(initPar,videoPath);
break;
case 2:
cout << "Insert video path: (current path: " << videoPath << ")"<<endl;
cin >> videoPath;
break;
case 3:
ParameterMenu();
break;
case 0:
LOG4CXX_INFO(loggerConsole,"Program closed");
return 0;
default:
cout << "Invalid option" << endl;
system("PAUSE");
break;
}
}
}