-
Notifications
You must be signed in to change notification settings - Fork 0
/
v1.py
216 lines (190 loc) · 7.31 KB
/
v1.py
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
"""first try for a testing program --- 18/16/2015"""
""" organisation:
- load files : 3 setting files and file created by user
- for each parameter, /!\ which one first? /!\
- run the program for k values of the parameter
- save the result
- choose the best value and use it for the next steps
- analyze (generate KPIs)
- parse the results into an Excel file
"""
""" /!\ BEFORE LAUNCH /!\
- check the video path (make one try to be sure)
"""
from tools import Tools
from parameters import Parameters
import time
from donnees import Donnees
from analysis import Analysis
from xlswriter import Xlswriter
import subprocess
debut = time.time()
"""importing parameters files"""
tools = Tools()
settings = Parameters(tools.openYml("caracteristiques_video.yml"))
""" parameters management strategy:
- each file is loaded as a canvas.
- creation of a parameter dictionary -> no : dictionary mix them all..
- every time we run the program, we change one parameter in the canvas and dump it into a parameter file.
+ open backup, parse it, empty it, close it.
+ copy CAM3 and change the name
- at the end of one parameter, launch the analysis program <and decide the value to adopt for this parameter> -> and changes at the end for a medium value.
"""
# script to call a command:
# >>> import os
# >>> import subprocess
# >>> subprocess.call(['./exe'])
# >>> subprocess.call(['cp', 'cam3.avi', 'results/new name.avi'])
# >>> subprocess.call(['vlc', 'name.avi', 'vlc://quit'])
settings.addOut(tools.openYml("outside.yml"))
settings.addDrone(tools.openYml("drones.yml"))
data = Donnees("main test")
f = open("testDonnees.txt", "w")
t = tools.openBackup()
data.appendResult("history10", t)
data.printMe(f)
a = {} # dictionary of analysis
xls = Xlswriter()
""" --- history --- + --- 10 to 100 --- """
i = 10
while i < 110:
stri = "history"
name = stri + str(i)
settings.change(stri, i)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 20
""" --- points_min --- + --- 3 to 15 --- ""
i = 3
while i < 15:
stri = "points_min"
name = stri + str(i)
settings.change(stri, i)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 3
"" --- surface_min --- + --- 5 to 50 --- ""
i = 5
while i < 55:
stri = "surface_min"
name = stri + str(i)
settings.change(stri, i)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 10
"" --- between_target --- ++ --- 100 to 1000 --- ""
i = 100
while i < 1000:
stri = "between_target"
name = stri + str(i)
settings.change(stri, i)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 100
"" --- distance_3d and distance_pixel --- ++ --- 0.5 to 5 and 20 to 200 --- ""
i = 0.5
while i < 5:
stri = "distance_3d"
name = stri + str(i)
settings.change(stri, i)
settings.change("distance_pixel", i/40)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 0.5
"" --- size_min --- ++ --- 2 to 50 --- ""
i = 2
while i < 52:
stri = "size_min"
name = stri + str(i)
settings.change(stri, i)
# subprocess.call(['./exe'])
t = tools.openBackup()
data.appendResult(name, t)
a[name] = Analysis(name, settings)
a[name].addResult(t)
subprocess.call(['cp', 'cam3.avi', 'results/'+name+'.avi'])
i += 5"""
""" et maintenant, petite seance de visionnage de CAM3 des familles."""
i = 10
while i < 110:
name = "history" + str(i)
# subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processus. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name], name, i)
i += 20
"""i = 3
while i < 15:
name = "points_min" + str(i)
subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processus. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name])
i += 3
i = 5
while i < 55:
name = "surface_min" + str(i)
subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processust. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name])
i += 10
i = 100
while i < 1000:
name = "between_target" + str(i)
subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processus. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name])
i += 100
i = 0.5
while i < 5:
name = "distance_3d" + str(i)
subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processus. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name])
i += 0.5
i = 2
while i < 52:
name = "size_min" + str(i)
subprocess.call(['vlc', 'results/'+name+'.avi', 'vlc://quit']) # reading CAM3 and closing it at the end
temp = input("nombre de faux positifs : **attention : ne taper que des chiffres! ou alors exit pour arreter le programme***\n") # reading the number
if temp == "exit":
raise NameError('arret volontaire du processus. For the watch.')
a[name].addFalsep(temp) # sending it to the analysis module
xls.add_analysis(a[name])
i += 5"""
xls.write()
fin = time.time()
print("fini en", fin - debut, "secondes")