-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcameramap_cleaner.py
101 lines (85 loc) · 2.65 KB
/
cameramap_cleaner.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
import joblib
import numpy as np
import math
from matplotlib import pyplot as plt
res1 = 31
res2 = 112.7
#res2 = 546
all_trees = joblib.load("data_memory/cameramap_raw_"+str(res1)+'_'+str(res2)+'.sav')
centerlist_arecont_noid = joblib.load('data_memory/cameramap_raw_noid_'+str(res1)+'_'+str(res2)+'.sav')
allx = []
ally = []
ids = []
#Nalezeni nejblizsiho bodu v listu
def find_nearest_point(target, list):
nearest_point = list[0]
min_dist = math.dist(target, nearest_point)
for point in list[1:]:
dist = math.dist(target, point)
if dist < min_dist:
min_dist = dist
nearest_point = point
return nearest_point, min_dist
for oo in range(len(all_trees)):
#jen pro vizualizaci
allx.append(all_trees[oo][2][0])
ally.append(all_trees[oo][2][1])
ids.append(all_trees[oo][1])
confbox = all_trees[oo][0]
boxid = all_trees[oo][1]
treex = all_trees[oo][2][0]
treey = all_trees[oo][2][1]
noidx = []
noidy = []
for uu in range(len(centerlist_arecont_noid)):
noidx.append(centerlist_arecont_noid[uu][0])
noidy.append(centerlist_arecont_noid[uu][1])
maxid = int(max(np.array(ids, dtype=np.float64)))
print(maxid)
final_list = []
sumx = 0
sumy = 0
numsum = 0
confsum = 0
timersum = 0
# kvuli limitovanemu oknu mam vzdy jen 1 strom v trackingu, ale tento pristup pocita i s pripadem, kde jsou ids prohazena
for cc in range(maxid+1):
for ll in range(len(all_trees)):
confbox = all_trees[ll][0]
boxid = all_trees[ll][1]
treex = all_trees[ll][2][0]
treey = all_trees[ll][2][1]
timerc = all_trees[ll][3]
if boxid == cc:
sumx = sumx + treex*confbox
sumy = sumy + treey*confbox
numsum = numsum + 1
confsum = confsum + confbox
timersum = timersum + timerc*confbox
else:
continue
if numsum == 0:
pass
else:
final_list.append([timersum/confsum, [sumx/confsum, sumy/confsum]])
sumx = 0
sumy = 0
numsum = 0
confsum = 0
timersum = 0
#Vizualizace
finalx = []
finaly = []
for ii in range(len(final_list)):
finalx.append(final_list[ii][1][0])
finaly.append(final_list[ii][1][1])
plt.figure(figsize=(6, 6))
plt.title("Mapa sadu z kamerového záznamu")
plt.xlabel("x [mm]")
plt.ylabel("y [mm]")
plt.scatter(allx, ally, s=7, c='y', marker='o', label='Detekce s ID')
plt.scatter(noidx, noidy, s=7, c='r', marker='o', label='Detekce bez ID')
plt.scatter(finalx, finaly, s=10, c='k', marker='x', label='Výsledná mapa')
plt.legend(loc='upper left')
plt.show()
#joblib.dump(final_list, "data_memory/cameramap_clean_"+str(res1)+"_"+str(res2)+".sav")