changes go gp

This commit is contained in:
NohamR
2023-08-18 08:53:35 +02:00
parent 2be296f9ae
commit 17fd85186a
25 changed files with 516 additions and 1409 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -7,22 +7,25 @@ def opencsv(file):
with open(file, newline='') as csvfile:
return [row for row in csv.DictReader(csvfile, delimiter=';')]
data = opencsv('traitementV2/vit13.txt')
data = opencsv('vt-pt4only.txt')
for i in range (len(data)-plusoumoins):
accel = (float(data[i+plusoumoins]['vitesse']) - float(data[i-plusoumoins]['vitesse'])) / (float(data[i+plusoumoins]['temps']) - float(data[i-plusoumoins]['temps']))*100
accel = (float(data[i+plusoumoins]['vitesse']) - float(data[i-plusoumoins]['vitesse'])) / (float(data[i+plusoumoins]['temps']) - float(data[i-plusoumoins]['temps']))*1000
print(f'accel {i}:', accel)
plt.figure(plusoumoins,figsize=[16,9])
plt.xlim([-1,476])
plt.ylim([-1, 1])
plt.ylim([-3, 10])
plt.plot([i],[accel], marker='o', linestyle='-')
# plt.show
# plt.pause(0.00001)
if i == 457-plusoumoins-2:
plt.savefig(f'traitementV2/accel±{plusoumoins}.png')
plt.clf
# with open("traitementV2/vit13.txt", 'a', encoding='utf-8') as file:
# file.write('\n' + str(i) + ';' + str(vitesse))
plt.xlabel("Numéro de l'image", fontsize = 16)
plt.ylabel("Accélération (sans unité)", fontsize = 16)
plt.xticks([0,50,100,150,200,250,300,350,400,450],fontsize = 14)
plt.yticks([-3,0,10], fontsize = 14)
plt.plot([i],[accel], marker='o', linestyle='-', color='blue')
if i == 457-plusoumoins-4:
print('saving')
plt.savefig(f'acceleration/accel±{plusoumoins}.png')
plt.clf

View File

@@ -104,8 +104,8 @@ while cap.isOpened():
tosave[key] = val
print(tosave)
with open("traitementV2/distance.txt", 'a', encoding='utf-8') as file:
file.write('\n' + str(tosave))
# with open("traitementV2/distance.txt", 'a', encoding='utf-8') as file:
# file.write('\n' + str(tosave))
if cv2.waitKey(25) & 0xFF == ord('q'):break
frame_nb = frame_nb + 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -1,30 +0,0 @@
import os
import cv2
def create_video_from_images(image_folder, output_video_path, fps=15):
image_files = sorted([f for f in os.listdir(image_folder) if f.endswith('.png')])
if not image_files:
print("Aucune image .png")
return
image_path = os.path.join(image_folder, image_files[0])
img = cv2.imread(image_path)
height, width, _ = img.shape
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(output_video_path, fourcc, fps, (width, height))
for image_file in image_files:
image_path = os.path.join(image_folder, image_file)
img = cv2.imread(image_path)
video_writer.write(img)
video_writer.release()
print(f"Vidéo créée avec succès : {output_video_path}")
if __name__ == "__main__":
input_image_folder = "traitement/vidresult"
output_video_path = "traitement/video_sortie.mp4"
create_video_from_images(input_image_folder, output_video_path)

View File

@@ -1,67 +0,0 @@
import matplotlib.pyplot as plt
from colour import Color
def rainbow_gradient(num_colors):
colors = []
gradient = list(Color("violet").range_to(Color("red"), num_colors))
for color in gradient:
colors.append(color.hex_l)
return colors
framenb = 1
keyvalues = []
with open('traitementV2/distance.txt', 'r') as f:
lignes = f.readlines()
for ligne in lignes:
line = eval(ligne)
allkeys = list(line.keys())
allkeys.sort()
linedict = {i: line[i] for i in allkeys}
linedict = {cle: valeur for cle, valeur in linedict.items() if valeur >= 0}
for key, value in linedict.items():
if key not in keyvalues:
keyvalues.append(key)
keypositions = {}
for key, i in zip(keyvalues, range(1, len(keyvalues)+1)):
keypositions[key] = i
print('keypositions: ', keypositions)
colors = rainbow_gradient(len(keypositions)+1)
with open('traitementV2/distance.txt', 'r') as f:
lignes = f.readlines()
for ligne in lignes:
line = eval(ligne)
allkeys = list(line.keys())
allkeys.sort()
linedict = {i: line[i] for i in allkeys}
linedict = {cle: valeur for cle, valeur in linedict.items() if valeur >= 0}
plt.figure(1,figsize=[16,9])
plt.xlim([-1,200])
plt.ylim([-1, len(keyvalues)+1])
plt.grid()
nb = 0
for key, value in linedict.items():
plt.plot([0,value],[keypositions[key], keypositions[key]], marker='o', linestyle='-', color=colors[keypositions[key]]) # , color=colors[key]
nb += 1
plt.draw()
plt.pause(0.0001)
plt.savefig(f'traitement/vidresult/{framenb}.png')
framenb += 1
plt.clf()

View File

@@ -12,7 +12,7 @@ framenb = 1
keyvalues = []
with open('traitementV2/distance.txt', 'r') as f:
with open('distance.txt', 'r') as f:
lignes = f.readlines()
for ligne in lignes:
line = eval(ligne)
@@ -34,7 +34,7 @@ for key, i in zip(keyvalues, range(1, len(keyvalues)+1)):
print('keypositions: ', keypositions)
colors = rainbow_gradient(len(keypositions)+1)
with open('traitementV2/distance.txt', 'r') as f:
with open('distance.txt', 'r') as f:
lignes = f.readlines()
for ligne in lignes:
line = eval(ligne)
@@ -49,6 +49,11 @@ with open('traitementV2/distance.txt', 'r') as f:
plt.xlim([-1,780])
plt.ylim([-20, 150])
plt.xlabel("Numéro de l'image", fontsize = 16)
plt.ylabel("Distance au point d'origine", fontsize = 16)
plt.xticks(fontsize = 14)
plt.yticks(fontsize = 14)
plt.grid()
nb = 0
@@ -57,7 +62,7 @@ with open('traitementV2/distance.txt', 'r') as f:
if key == 13:
# print('value: ', value)
# print(framenb)
with open("traitementV2/pt13.txt", 'a', encoding='utf-8') as file:
with open("pt4only.txt", 'a', encoding='utf-8') as file:
file.write('\n' + str(framenb) + ';' + str(value))
plt.plot([framenb],[value], marker='o', linestyle='-', color=colors[keypositions[key]]) # , color=colors[key]
@@ -67,6 +72,6 @@ with open('traitementV2/distance.txt', 'r') as f:
# plt.draw()
# plt.pause(0.0001)
if framenb == 780:
plt.savefig(f'traitementV2/{framenb}.png')
framenb += 1
plt.savefig('position-temps-pt4.png')
framenb += 1
# plt.clf()

View File

@@ -1,457 +0,0 @@
temps;vitesse
0;0.2203695636911355
1;0.22161122417978193
2;0.2218895757246934
3;0.22414714122121102
4;0.2251793424582029
5;0.22640301448957026
6;0.22637916369574068
7;0.22773771622202058
8;0.22773771622202058
9;0.23076676980392818
10;0.2320941807387388
11;0.23329454949710868
12;0.23463617025213993
13;0.23565445618186323
14;0.23565445618186323
15;0.23807971549773826
16;0.23872824527431533
17;0.23936223880725904
18;0.23972979102989075
19;-0.0
20;-0.0
21;0.011960565173266524
22;0.01148819777981944
23;0.0004725094603026778
24;0.011260481393283802
25;0.011260481393283802
26;0.011746828823665586
27;0.0010351763898071233
28;0.012582311854087959
29;0.012582311854087959
30;0.012582311854087959
31;0.01355018199671011
32;0.01355018199671011
33;0.01355018199671011
34;0.01355018199671011
35;0.015054516640458959
36;-0.012109053184948499
37;0.013902814872813295
38;0.014478578893954213
39;0.014478578893954213
40;0.014478578893954213
41;0.014478578893954213
42;0.013334780597309765
43;0.012759016576168847
44;-0.0
45;-0.0
46;-0.0
47;0.012759016576168847
48;0.013906765733465639
49;0.01333100171232472
50;0.01333100171232472
51;0.013906765733465639
52;0.013334780597309765
53;0.013334780597309765
54;0.012759016576168847
55;0.0005757640211409185
56;0.0005757640211409185
57;0.013906765733465639
58;0.013906765733465639
59;-0.0011437982966444487
60;-0.0005719851361558731
61;-0.0005719851361558731
62;-0.0
63;0.0005719851361558731
64;0.0005719851361558731
65;-0.0005719851361558731
66;-0.0005719851361558731
67;-0.0005719851361558731
68;-0.0005719851361558731
69;-0.0011441423255762941
70;-0.0011441423255762941
71;-0.0011441423255762941
72;-0.0011441423255762941
73;-0.0011437982966444487
74;-0.0011437982966444487
75;-0.0011437982966444487
76;-0.0011437982966444487
77;-0.0011437982966444487
78;-0.0011437982966444487
79;-0.0011437982966444487
80;-0.0
81;-0.0
82;-0.0
83;-0.0
84;-0.0
85;-0.0
86;-0.0005719851361558731
87;-0.0005719851361558731
88;-0.0005719851361558731
89;-0.0005719851361558731
90;-0.0
91;-0.0005721571894204209
92;-0.0005721571894204209
93;0.012186859386748426
94;0.012759016576168847
95;-0.0005719851361558731
96;-0.0005719851361558731
97;-0.0
98;-0.0
99;-0.0
100;-0.0
101;-0.0005719851361558731
102;-0.0005719851361558731
103;-0.0
104;-0.0
105;-0.0
106;-0.0
107;0.0005721571894204209
108;0.0005721571894204209
109;0.0005721571894204209
110;0.0005721571894204209
111;-0.0
112;-0.0
113;-0.0
114;-0.0
115;-0.0
116;-0.0
117;-0.0
118;-0.0
119;-0.0
120;-0.0
121;-0.0
122;-0.0
123;0.013252851481592947
124;-0.0
125;-0.0004726515912603477
126;-0.0004726515912603477
127;0.021362463645277722
128;-0.0
129;0.00044371373873420395
130;-0.0
131;0.00044371373873420395
132;0.020492490013077597
133;0.009836912136323435
134;0.009836912136323435
135;0.009836912136323435
136;0.020492490013077597
137;0.020492490013077597
138;0.020492490013077597
139;0.009836912136323435
140;0.009836912136323435
141;0.009836912136323435
142;0.04073546713828959
143;0.020492490013077597
144;0.020492490013077597
145;0.020492490013077597
146;0.04073546713828959
147;0.030209799945381217
148;0.04030320879255594
149;0.04030320879255594
150;0.04030320879255594
151;0.03716301974339231
152;0.04702658077167198
153;0.028466926871609226
154;0.04743138493067205
155;0.04743138493067205
156;0.04743138493067205
157;0.05562060431307058
158;0.04621661254184936
159;0.05562060431307058
160;0.04621661254184936
161;0.03693688057713674
162;0.055098321507082784
163;0.054634938366909254
164;0.054634938366909254
165;0.03228614828394072
166;0.07054320547023586
167;0.07054320547023586
168;0.07107349749945478
169;0.08189096244463166
170;0.057399937794856
171;0.06911968220699151
172;0.06911968220699151
173;0.08091313027129808
174;0.06817841524786018
175;0.06918686711188532
176;0.06868271524509405
177;0.08091313027129808
178;0.0793993408437983
179;0.09063003662305114
180;0.05370249527923793
181;0.07789532159961324
182;0.07939985304779656
183;0.07839697905900257
184;0.05370249527923793
185;0.06578014667048791
186;0.05371729219459618
187;0.06588440913296337
188;0.06488706923856222
189;0.10428608927730694
190;0.09262915351661279
191;0.11456328994395969
192;0.10270764503588868
193;0.11275493295541236
194;0.1231909421999288
195;0.11351277383891235
196;0.11419057305129372
197;0.10218140250594553
198;0.12786311621089405
199;0.12782828937810417
200;0.126982070267033
201;0.13819501849986685
202;0.13819501849986685
203;0.13773700682095086
204;0.20986059399401907
205;0.22809961711044605
206;0.19343403304206427
207;0.15468712137814916
208;0.1642862472723449
209;0.14593708369241468
210;0.1555917690969187
211;0.15345495985036142
212;0.15386320236577225
213;0.1537805059245579
214;0.15341371758562902
215;0.1621947218447349
216;0.17304584161072317
217;0.17168115382547425
218;0.17168115382547425
219;0.1802819943299281
220;0.17894099890872123
221;0.18799470542605629
222;0.18844183490072938
223;0.1974042707813599
224;0.20666096476480048
225;0.19620867849882603
226;0.1967052939212655
227;0.18875309442759622
228;0.18920178015452221
229;0.18875309442759622
230;0.1876716289368531
231;0.17572728439443602
232;0.16424767422546793
233;0.18426186833031544
234;0.19530023785993472
235;0.206653823321923
236;0.1939326018300237
237;0.20335595468001194
238;0.20438032518288757
239;0.2027144122263026
240;0.20088741758294834
241;0.21163747032625224
242;0.1221520470411114
243;0.12127851338912726
244;0.16324211515611572
245;0.19790263885584905
246;0.19635449944313615
247;0.21877399722244656
248;0.21666968603173847
249;0.20609016135237673
250;0.20559597304424782
251;0.2352545661651832
252;0.23580831967826785
253;0.21541380211851602
254;0.2240419801126861
255;0.222918180875212
256;0.222918180875212
257;0.2319038277073582
258;0.22180280579073788
259;0.22160123425706912
260;0.2412262444341634
261;0.24002756655053198
262;0.22882209488636707
263;0.2378284102203201
264;0.24773674221416206
265;0.23753889637291867
266;0.2562003501295016
267;0.25544566124235574
268;0.2443602711506079
269;0.2642510026784953
270;0.27345291539276073
271;0.26154154348005076
272;0.27071865240177423
273;0.259405959973723
274;0.259405959973723
275;0.2769387345289279
276;0.2858734919181376
277;0.28396556094726877
278;0.29425444033258424
279;0.2923109275392159
280;0.2816202302437083
281;0.2786591208003557
282;0.2873341972000685
283;0.28695664392914244
284;0.28514432989940725
285;0.29462769070564426
286;0.28504475114353167
287;0.3025541274357064
288;0.3110268019872378
289;0.2796441925217691
290;0.296910462827415
291;0.3155755737309313
292;0.2954451288233936
293;0.29369883985111084
294;0.31093566845522735
295;0.2990277561647108
296;0.3172934776306726
297;0.30726390997961284
298;0.28763889980251856
299;0.29439841905997993
300;0.31046979071580766
301;0.30896834236057985
302;0.3071347991575985
303;0.33142505790255794
304;0.31229130338078975
305;0.3206420912518508
306;0.3199695863055007
307;0.308450505721209
308;0.3230022559289241
309;0.3217989907649819
310;0.31308634567415194
311;0.3361487822750705
312;0.35108888279863865
313;0.3384273926525907
314;0.3368465599468467
315;0.33496306844540114
316;0.32650118370343995
317;0.339778241026287
318;0.3466632629277727
319;0.3352754018500593
320;0.33312317250810103
321;0.34798045292319857
322;0.3397209118621466
323;0.3448776906514237
324;0.35881040017592364
325;0.34836896045110083
326;0.35335994507359986
327;0.3680262688726035
328;0.35119420532043
329;0.3554992984160279
330;0.3622210133188524
331;0.36770075395032403
332;0.37085169275237534
333;0.36963651906078243
334;0.36147181951144086
335;0.3941816027938007
336;0.3936387896130647
337;0.390529926967831
338;0.3805311085825444
339;0.3851561016912019
340;0.37755622411713685
341;0.3717178215493056
342;0.3845876504169748
343;0.38996688341048613
344;0.4030387372272647
345;0.4073985966057478
346;0.3836449336837672
347;0.3990009992158696
348;0.411011671306265
349;0.38122587513303413
350;0.37824763491968855
351;0.38271168121326465
352;0.3901028798570653
353;0.38840348333529445
354;0.41278326530522785
355;0.39694974273228933
356;0.395135243051521
357;0.4117524371612199
358;0.41759275939765256
359;0.4177524132351629
360;0.42439295325568366
361;0.41453274758581293
362;0.4313188651008514
363;0.4297118049640075
364;0.42279371149636724
365;0.4191763504222161
366;0.4220170531558322
367;0.4129392044628501
368;0.42717360514310826
369;0.43993466955000315
370;0.4281513389703908
371;0.4390383140463713
372;0.4447076054955774
373;0.4215087160245048
374;0.4365720425299255
375;0.43871000558769757
376;0.4399462070013526
377;0.44244276988794345
378;0.45405170458254246
379;0.4408220718517713
380;0.4481677545496066
381;0.447153523259126
382;0.4521037905540802
383;0.4518242946827663
384;0.45705522239968616
385;0.44034310833362933
386;0.45482573865439074
387;0.4762161718306143
388;0.48121744246250797
389;0.4844167100083613
390;0.48168865716090675
391;0.4773929593004052
392;0.4819562150645929
393;0.4950831420747329
394;0.5038308729785489
395;0.48323921723559043
396;0.48153449385666597
397;0.4668320916233354
398;0.48594455970340344
399;0.49818791401006396
400;0.47601278831958244
401;0.4868164104093057
402;0.4947692299860013
403;0.48588422902629
404;0.508205294066336
405;0.525402024804196
406;0.50672794196171
407;0.4956407924943794
408;0.5025562271650974
409;0.48109765730895965
410;0.5000635872937892
411;0.5132840339685756
412;0.5057665217144769
413;0.5081396680990065
414;0.5102626251063773
415;0.494175805565638
416;0.5102453301654887
417;0.5222599290074934
418;0.5159585115236797
419;0.5115524959795529
420;0.5109705489825482
421;0.4995681543030294
422;0.5239863483711705
423;0.532734825909475
424;0.5180861575211296
425;0.5205142205126738
426;0.519160360197855
427;0.5086432506051207
428;0.5219748773259202
429;0.5359982238209609
430;0.5251215677058093
431;0.5276132051436483
432;0.5257720959481818
433;0.5163308255702512
434;0.533236107860266
435;0.5475268374591108
436;0.5315416537618848
437;0.5369325597744949
438;0.5372508402384074
439;0.5255344555829528
440;0.541927055756813
441;0.5548024080287647
442;0.5443587727463455
443;0.5396235513142538
444;0.5486688313960989
445;0.5288826625892584
446;0.5430385470557738
447;0.55902048785306
448;0.5476961730646185
449;0.55121068001838
450;0.5503876421136936
451;0.5322727773384714
452;0.5526050102395345
453;0.5612703298948206
454;0.5363418674791338
455;0.5289119989931144

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

455
traitementV2/vt-pt4only.txt Normal file
View File

@@ -0,0 +1,455 @@
temps;vitesse
0;0
1;-0.0
2;-0.0
3;0
4;-0.0
5;0
6;-0.010942817183590137
7;0
8;0.004377126873436055
9;0
10;-0.0
11;-0.0
12;-0.0
13;-0.0
14;-0.0
15;-0.007295211455726758
16;0
17;0.021882333585267588
18;0
19;-0.010939516401677452
20;-0.0
21;0.010569141957433885
22;0.010134433253955421
23;0.010134433253955421
24;0.010134433253955421
25;0.0004347087034784636
26;0.010784838732075393
27;0.010784838732075393
28;0.011231484331405603
29;0.0009451610515630255
30;0.01148819777981944
31;0.01148819777981944
32;0.01148819777981944
33;0.0127950232086107
34;0.0127950232086107
35;0.0127950232086107
36;0.0127950232086107
37;0.013620753150891438
38;-0.010955810024477214
39;0.012578737265878695
40;0.012064801492804074
41;0.012064801492804074
42;0.012064801492804074
43;0.012064801492804074
44;0.012064801492804074
45;0.011543872140343242
46;0.0005175103612838852
47;0.0005175103612838852
48;0.0005175103612838852
49;0.012061382501627128
50;0.012064801492804074
51;0.011543872140343242
52;0.011543872140343242
53;0.000520929352460831
54;0.000520929352460831
55;0.012582311854087959
56;0.012061382501627128
57;0.012064801492804074
58;0.012064801492804074
59;0.012064801492804074
60;0.012064801492804074
61;-0.0005173547642515684
62;-0.0
63;-0.0005175103612838852
64;-0.0
65;-0.0
66;-0.0
67;-0.0010351763898071233
68;-0.0010351763898071233
69;-0.0010351763898071233
70;-0.0010351763898071233
71;-0.0005175103612838852
72;-0.0005175103612838852
73;-0.0005175103612838852
74;-0.0005175103612838852
75;-0.0010348651255354536
76;-0.0010348651255354536
77;-0.0010348651255354536
78;-0.0010348651255354536
79;-0.0010348651255354536
80;-0.0010348651255354536
81;-0.0010348651255354536
82;-0.0
83;-0.0
84;-0.0
85;-0.0
86;-0.0
87;-0.0
88;-0.0005175103612838852
89;-0.0010351763898071233
90;-0.0010351763898071233
91;-0.0010351763898071233
92;-0.0
93;-0.0
94;-0.0
95;0.011543872140343242
96;0.011543872140343242
97;-0.0005175103612838852
98;-0.0005175103612838852
99;-0.0
100;-0.0
101;-0.0
102;-0.0
103;-0.0005175103612838852
104;-0.0005175103612838852
105;-0.0
106;-0.0
107;-0.0
108;-0.0
109;0.000517666028523238
110;0.000517666028523238
111;0.000517666028523238
112;0.000517666028523238
113;-0.0
114;-0.0
115;-0.0
116;-0.0
117;-0.0
118;-0.0
119;-0.0
120;-0.0
121;0.011990675150012666
122;-0.0
123;-0.0004348394639595199
124;-0.0004348394639595199
125;0.019653466553655505
126;-0.0
127;-0.0
128;-0.0004102259093957735
129;-0.0
130;0.018945886993222683
131;0.00950472958260046
132;0.00950472958260046
133;0.00950472958260046
134;0.018945886993222683
135;0.018945886993222683
136;0.018945886993222683
137;0.009094503673204685
138;0.009094503673204685
139;0.009094503673204685
140;0.037661092259928114
141;0.018945886993222683
142;0.018945886993222683
143;0.018945886993222683
144;0.037661092259928114
145;0.027929815043843013
146;0.03726145718557058
147;0.03726145718557058
148;0.03726145718557058
149;0.03450851833315
150;0.04366753928798112
151;0.026433574952208567
152;0.04404342886419548
153;0.04404342886419548
154;0.04404342886419548
155;0.05164770400499411
156;0.042915425931717266
157;0.05164770400499411
158;0.042915425931717266
159;0.04329153832699362
160;0.04329153832699362
161;0.0425392020526077
162;0.0425392020526077
163;0.033922419569207767
164;0.06025565467249313
165;0.06070861244745096
166;0.06070861244745096
167;0.04947616942806506
168;0.07461176578288663
169;0.07368701478147778
170;0.0741701697414328
171;0.08443215635117933
172;0.062118111670272605
173;0.07463966372329449
174;0.07418032535577355
175;0.07372085202496047
176;0.06073888130299502
177;0.07097129301298095
178;0.07097129301298095
179;0.08257403336766882
180;0.08394482868712475
181;0.08303109905289022
182;0.04892894014330567
183;0.07051409333717515
184;0.07051409333717515
185;0.0815996887699097
186;0.058648648440891155
187;0.09883891681439659
188;0.08914132792201304
189;0.08914132792201304
190;0.09824923857134918
191;0.11448275082868105
192;0.11336356818885147
193;0.13346985991391946
194;0.10335868854246133
195;0.10253793996138179
196;0.11637070362964692
197;0.1082431206684953
198;0.11724475052837988
199;0.11693789483320473
200;0.12671804627527478
201;0.12629680039256527
202;0.2024306520338581
203;0.22005316992828314
204;0.18816083258537192
205;0.16139746382897185
206;0.16044850820956186
207;0.1427350018147581
208;0.1516173123869018
209;0.15001691457379593
210;0.15039249768797391
211;0.15197562339182524
212;0.15122477358924186
213;0.14921914409715611
214;0.1579608669513155
215;0.1650875941993732
216;0.16550099873014204
217;0.17382729799197136
218;0.1750686053225212
219;0.17336648810867103
220;0.17336648810867103
221;0.18120044941062588
222;0.18848289208788088
223;0.18966618128345658
224;0.1897166078753912
225;0.1978784504229614
226;0.1982373990045022
227;0.18790141453350032
228;0.1971441297166376
229;0.18035626107619604
230;0.18035626107619604
231;0.19855098298969376
232;0.1875929587012825
233;0.1869717500223887
234;0.17653574077787226
235;0.18511636959893352
236;0.19555237884344995
237;0.20577410672723026
238;0.19256954371939644
239;0.20183244239602516
240;0.21243178945170524
241;0.22033978938588375
242;0.22033978938588375
243;0.22033978938588375
244;0.13881688251410448
245;0.11803760947881801
246;0.1646749563956237
247;0.1956348637306012
248;0.1851215353702916
249;0.2339368770004083
250;0.22296984401852407
251;0.2044703221963045
252;0.22223645911957912
253;0.2297944597785013
254;0.23068832859110056
255;0.23911317018143746
256;0.21956733743049603
257;0.21885329121977057
258;0.23660925280857015
259;0.23543091095892418
260;0.23543091095892418
261;0.23507219530824774
262;0.24360719505890874
263;0.23428105065181964
264;0.24145425895155592
265;0.23991444387948896
266;0.2403441254565897
267;0.24826404314360945
268;0.2561622634784915
269;0.26487376492106207
270;0.2627269956345173
271;0.2632164786716461
272;0.2632164786716461
273;0.2690075581247552
274;0.2775116154191342
275;0.2756809304551768
276;0.2833369214121893
277;0.2823155130781621
278;0.2823155130781621
279;0.2890516685719318
280;0.29855354237280196
281;0.28848570835992726
282;0.2862860908144674
283;0.2748773413366191
284;0.2748773413366191
285;0.2903195438742817
286;0.2888726662435265
287;0.2890099108426525
288;0.29556864207175526
289;0.30352855244356813
290;0.30352855244356813
291;0.28267261216100725
292;0.2986606917702544
293;0.314763890508947
294;0.30393773994676954
295;0.2951660937427999
296;0.2951660937427999
297;0.29197363646843905
298;0.31565342112922545
299;0.3141186264495194
300;0.30323874457058814
301;0.31697401901793837
302;0.31697401901793837
303;0.31484110766992146
304;0.305697651063039
305;0.3124221658873007
306;0.31660208301130244
307;0.32490772972724763
308;0.32490772972724763
309;0.32826685068759515
310;0.33345854441982137
311;0.3385709454713389
312;0.3373416270075331
313;0.3440421238343141
314;0.3440421238343141
315;0.3391703046710108
316;0.33731578208687957
317;0.33547485796017085
318;0.3337204905316029
319;0.33885337418353056
320;0.33885337418353056
321;0.33478938072568065
322;0.33954628688620236
323;0.3458830683465298
324;0.3505915561630341
325;0.35541814823180606
326;0.35541814823180606
327;0.35143132618766854
328;0.3498471246007433
329;0.36234283440589027
330;0.36555989979759945
331;0.36367617437881233
332;0.36367617437881233
333;0.3860790697385669
334;0.3699927271713194
335;0.3747613148141193
336;0.3728684205618713
337;0.3845925141885761
338;0.3845925141885761
339;0.3869296688892331
340;0.384033034938042
341;0.38812550195316997
342;0.3924678807451179
343;0.381160129475901
344;0.381160129475901
345;0.39580388455183607
346;0.4072791399660344
347;0.3927404498339047
348;0.3828898179123402
349;0.39157266844160815
350;0.4037693352276491
351;0.3907592822054355
352;0.4032614862433333
353;0.39339032000342705
354;0.3913905517789365
355;0.4067408175955542
356;0.41651985736267
357;0.411599060669702
358;0.41318358328077465
359;0.4086127077583232
360;0.4291607604255751
361;0.4224308302204404
362;0.4249739897788303
363;0.4217290623396352
364;0.4150819444966643
365;0.4106644392854614
366;0.419405305140687
367;0.43070067217611624
368;0.4333360869255009
369;0.4392009934834866
370;0.4399912966501636
371;0.43127463558256585
372;0.4313271661524773
373;0.43763890866721494
374;0.44283672795150053
375;0.4319903770845048
376;0.44314652514909625
377;0.4346399767844577
378;0.4460016900419338
379;0.4449908061491429
380;0.45785991884578947
381;0.4531602778473832
382;0.44944423700572217
383;0.441108882864228
384;0.45431607039684374
385;0.45326369682534373
386;0.4651886175455653
387;0.45666068980912483
388;0.4577223540371697
389;0.4702820633438385
390;0.48145370359188316
391;0.48651589235741466
392;0.4836148168392575
393;0.48731807782563596
394;0.4800578470249624
395;0.4800578470249624
396;0.5017902293810208
397;0.4856949025014809
398;0.48614840600776976
399;0.4865881670632164
400;0.4888552770073843
401;0.4888552770073843
402;0.47884695620203593
403;0.490438674255675
404;0.49413565424420663
405;0.5039986156297045
406;0.5102473754706702
407;0.5102473754706702
408;0.5105171227056805
409;0.4945454769729037
410;0.5026846507240622
411;0.49965939374609086
412;0.5014802418098159
413;0.5014802418098159
414;0.5121513387071668
415;0.5087791829250206
416;0.5169373999813897
417;0.5084286665157892
418;0.5107179974445734
419;0.5107179974445734
420;0.5184978989595594
421;0.5163807851211278
422;0.5148045023584945
423;0.5159257971509424
424;0.5242837642960082
425;0.5242837642960082
426;0.5195108421385936
427;0.5229577036001578
428;0.5212327362237689
429;0.5258483382356569
430;0.5237291376085004
431;0.5237291376085004
432;0.5264539405067618
433;0.5275069047536852
434;0.5268618881849915
435;0.5342745933700135
436;0.5365584336864883
437;0.5396998296933464
438;0.5395061067699929
439;0.5400779144528753
440;0.5406837992548215
441;0.538216563645866
442;0.5429019602819141
443;0.5429019602819141
444;0.5417631757944473
445;0.5406640801339282
446;0.5475836175130739
447;0.5448229942565233
448;0.5459606928204112
449;0.5459606928204112
450;0.5490177197131091
451;0.5448964143145137
452;0.5398147467799517
453;0.5275731965911182

View File

@@ -1,28 +1,42 @@
import csv
import matplotlib.pyplot as plt
plusoumoins = 19
# plusoumoins = 6
def opencsv(file):
with open(file, newline='') as csvfile:
return [row for row in csv.DictReader(csvfile, delimiter=';')]
data = opencsv('traitementV2/pt13.txt')
data = opencsv('pt4only.txt')
def tester(plusoumoins):
for i in range (len(data)-plusoumoins):
for i in range (len(data)-plusoumoins):
vitesse = -(float(data[i+plusoumoins]['distance']) - float(data[i-plusoumoins]['distance'])) / (float(data[i+plusoumoins]['temps']) - float(data[i-plusoumoins]['temps']))
# print(f'vitesse {i}:', -vitesse)
##corection des points manquants
if i <plusoumoins:
vitesse = -(float(data[i+1]['distance']) - float(data[i-1]['distance'])) / (float(data[i+1]['temps']) - float(data[i-1]['temps']))
if vitesse>0.05 or vitesse<-0.05:
vitesse=0
else :
vitesse = -(float(data[i+plusoumoins]['distance']) - float(data[i-plusoumoins]['distance'])) / (float(data[i+plusoumoins]['temps']) - float(data[i-plusoumoins]['temps']))
print(f'vitesse {i}:', vitesse)
plt.figure(plusoumoins,figsize=[16,9])
plt.xlim([-1,476])
plt.ylim([-1, 1])
plt.figure(plusoumoins,figsize=[16,9])
plt.xlim([-1,476])
plt.ylim([-0.3, 1])
plt.xlabel("Numéro de l'image", fontsize = 16)
plt.ylabel("Vitesse (sans unité)", fontsize = 16)
plt.xticks([0,50,100,150,200,250,300,350,400,450,500],fontsize = 14)
# plt.yticks([-0.3,0,1], fontsize = 14)
plt.yticks([i/100 for i in range(-30, 100, 5)], fontsize = 14)
plt.plot([i],[vitesse], marker='o', linestyle='-')
# plt.show
# plt.pause(0.00001)
# if i == 474-plusoumoins:
# plt.savefig(f'traitementV2/vitesse±{plusoumoins}.png')
# plt.clf
with open("traitementV2/vit13.txt", 'a', encoding='utf-8') as file:
file.write('\n' + str(i) + ';' + str(vitesse))
plt.plot([i],[vitesse], marker='o', linestyle='-', color='blue')
if i == 474-plusoumoins:
plt.savefig(f'vitesse/vitesse±{plusoumoins}.png')
plt.clf
# with open("vt-pt4only.txt", 'a', encoding='utf-8') as file:
# file.write('\n' + str(i) + ';' + str(vitesse))
tester(21)

View File

@@ -1,35 +0,0 @@
import csv
import matplotlib.pyplot as plt
# plusoumoins = 6
def opencsv(file):
with open(file, newline='') as csvfile:
return [row for row in csv.DictReader(csvfile, delimiter=';')]
data = opencsv('traitementV2/pt13.txt')
def tester(plusoumoins):
for i in range (len(data)-plusoumoins):
# print(data[i+1]['temps'])
# print(data[i-1]['temps'])
# print(data[i+1]['distance'])
# print(data[i-1]['distance'])
vitesse = (float(data[i+plusoumoins]['distance']) - float(data[i-plusoumoins]['distance'])) / (float(data[i+plusoumoins]['temps']) - float(data[i-plusoumoins]['temps']))
print(f'vitesse {i}:', -vitesse)
plt.figure(plusoumoins,figsize=[16,9])
plt.xlim([-1,476])
plt.ylim([-1, 1])
plt.plot([i],[-vitesse], marker='o', linestyle='-')
# plt.show
# plt.pause(0.00001)
if i == 474-plusoumoins:
plt.savefig(f'traitementV2/vitesse±{plusoumoins}.png')
plt.clf
# for i in range(1, 20):
# tester(i)
tester(100)