forked from bastianwandt/RepNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot17j.py
More file actions
109 lines (84 loc) · 4.33 KB
/
plot17j.py
File metadata and controls
109 lines (84 loc) · 4.33 KB
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
def plot17j(poses, show_animation=False):
import matplotlib as mpl
mpl.use('Qt5Agg')
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as anim
from mpl_toolkits.mplot3d import axes3d, Axes3D
fig = plt.figure()
if not show_animation:
plot_idx = 1
frames = np.linspace(start=0, stop=poses.shape[0]-1, num=10).astype(int)
for i in frames:
ax = fig.add_subplot(2, 5, plot_idx, projection='3d')
pose = poses[i]
x = pose[0:16]
y = pose[16:32]
z = pose[32:48]
ax.scatter(x, y, z)
ax.plot(x[([0, 1])], y[([0, 1])], z[([0, 1])])
ax.plot(x[([1, 2])], y[([1, 2])], z[([1, 2])])
ax.plot(x[([3, 4])], y[([3, 4])], z[([3, 4])])
ax.plot(x[([4, 5])], y[([4, 5])], z[([4, 5])])
ax.plot(x[([0, 6])], y[([0, 6])], z[([0, 6])])
ax.plot(x[([3, 6])], y[([3, 6])], z[([3, 6])])
ax.plot(x[([6, 7])], y[([6, 7])], z[([6, 7])])
ax.plot(x[([7, 8])], y[([7, 8])], z[([7, 8])])
ax.plot(x[([8, 9])], y[([8, 9])], z[([8, 9])])
ax.plot(x[([7, 10])], y[([7, 10])], z[([7, 10])])
ax.plot(x[([10, 11])], y[([10, 11])], z[([10, 11])])
ax.plot(x[([11, 12])], y[([11, 12])], z[([11, 12])])
ax.plot(x[([7, 13])], y[([7, 13])], z[([7, 13])])
ax.plot(x[([13, 14])], y[([13, 14])], z[([13, 14])])
ax.plot(x[([14, 15])], y[([14, 15])], z[([14, 15])])
# Create cubic bounding box to simulate equal aspect ratio
max_range = np.array([x.max() - x.min(), y.max() - y.min(), z.max() - z.min()]).max()
Xb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][0].flatten() + 0.5 * (x.max() + x.min())
Yb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][1].flatten() + 0.5 * (y.max() + y.min())
Zb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][2].flatten() + 0.5 * (z.max() + z.min())
for xb, yb, zb in zip(Xb, Yb, Zb):
ax.plot([xb], [yb], [zb], 'w')
ax.axis('equal')
ax.axis('off')
ax.set_title('frame = ' + str(i))
plot_idx += 1
# this uses QT5Agg backend
# you can identify the backend using plt.get_backend()
# delete the following two lines and resize manually if it throws an error
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
plt.show()
else:
def update(i):
ax.clear()
pose = poses[i]
x = pose[0:16]
y = pose[16:32]
z = pose[32:48]
ax.scatter(x, y, z)
ax.plot(x[([0, 1])], y[([0, 1])], z[([0, 1])])
ax.plot(x[([1, 2])], y[([1, 2])], z[([1, 2])])
ax.plot(x[([3, 4])], y[([3, 4])], z[([3, 4])])
ax.plot(x[([4, 5])], y[([4, 5])], z[([4, 5])])
ax.plot(x[([0, 6])], y[([0, 6])], z[([0, 6])])
ax.plot(x[([3, 6])], y[([3, 6])], z[([3, 6])])
ax.plot(x[([6, 7])], y[([6, 7])], z[([6, 7])])
ax.plot(x[([7, 8])], y[([7, 8])], z[([7, 8])])
ax.plot(x[([8, 9])], y[([8, 9])], z[([8, 9])])
ax.plot(x[([7, 10])], y[([7, 10])], z[([7, 10])])
ax.plot(x[([10, 11])], y[([10, 11])], z[([10, 11])])
ax.plot(x[([11, 12])], y[([11, 12])], z[([11, 12])])
ax.plot(x[([7, 13])], y[([7, 13])], z[([7, 13])])
ax.plot(x[([13, 14])], y[([13, 14])], z[([13, 14])])
ax.plot(x[([14, 15])], y[([14, 15])], z[([14, 15])])
# Create cubic bounding box to simulate equal aspect ratio
max_range = np.array([x.max() - x.min(), y.max() - y.min(), z.max() - z.min()]).max()
Xb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][0].flatten() + 0.5 * (x.max() + x.min())
Yb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][1].flatten() + 0.5 * (y.max() + y.min())
Zb = 0.5 * max_range * np.mgrid[-1:2:2, -1:2:2, -1:2:2][2].flatten() + 0.5 * (z.max() + z.min())
for xb, yb, zb in zip(Xb, Yb, Zb):
ax.plot([xb], [yb], [zb], 'w')
plt.axis('equal')
a = anim.FuncAnimation(fig, update, frames=poses.shape[0], repeat=False)
plt.show()
return