-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProbMapPlotter.py
87 lines (77 loc) · 1.92 KB
/
ProbMapPlotter.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
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
import numpy as np
import cv2
from os import path
basename = "./probMaps"
keypoints_mapping = [
"Head",
"Neck",
"R-Sho",
"R-Elb",
"R-Wr",
"L-Sho",
"L-Elb",
"L-Wr",
"R-Hip",
"R-Knee",
"R-Ank",
"L-Hip",
"L-Knee",
"L-Ank",
"Chest",
]
# it is used to space the graph over the y axis and to pick less values over the x axis
resize = 8
def read_file(filename):
X = []
Y = []
Z = []
x = 0
y = 0
with open(filename, "r") as f;
for line in f:
if line.strip():
values = line.split(" ")
if y % resize == 0:
for indx, el in enumerate(values):
if indx % resize == 0:
Z.append(float(el))
X.append(x)
Y.append(y / resize)
x += 1
x = 0
y += 1
return (X,Y,Z)
resp = None
while resp == None:
print("q: QUIT")
for indx, el in enumerate(keypoints_mapping):
print(f"{indx+1}: {el}")
i = input("What do you want to plot: ")
if i == "q":
exit()
else:
try:
resp = int(i)
if not (0 < resp <= keypoints_mapping.__len__() + 1):
raise ValueError("index out of range")
except:
resp = None
print("Inserted value incorrect!")
filename = f"{basename}{keypoints_mapping[resp-1]}"
if not path.isfile(filename):
print("You need to run probMapsRetreiver.py")
exit(-1)
X, Y, Z = read_file(f"{filename}.txt")
Z.reverse()
Z = np.array(Z)
Z = Z.transpose()
X.reverse()
fig = plt.figure()
ax = plt.axes(projection="3d")
width = int(440 / resize)
height = int(640 / resize)
dim = (width, height)
ax.plot_wireframe(X, Y, np.array([Z, Z]), rstride=100, cstride=100)
plt.show()