v2 working
This commit is contained in:
57
3ddisplay_replay.py
Normal file
57
3ddisplay_replay.py
Normal file
@ -0,0 +1,57 @@
|
||||
import pickle
|
||||
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
with open("replay_xyz.pkl", "rb") as f:
|
||||
points3DList = pickle.load(f)
|
||||
|
||||
skeleton = [
|
||||
[0, 1], [0, 2], # nose -> eyes
|
||||
[1, 3], [2, 4], # eyes -> ears
|
||||
# [0, 5], [0, 6], # nose -> shoulders
|
||||
[5, 7], [7, 9], # left arm
|
||||
[6, 8], [8, 10], # right arm
|
||||
[5, 6], # shoulders
|
||||
[5, 11], [6, 12], # shoulders -> hips
|
||||
[11, 12], # hips
|
||||
[11, 13], [13, 15], # left leg
|
||||
[12, 14], [14, 16] # right leg
|
||||
]
|
||||
|
||||
plt.ion() # włączenie trybu interaktywnego
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
# Tworzymy początkowy wykres punktów
|
||||
points_plot = ax.scatter([], [], [], c='r', marker='o', s=50)
|
||||
lines_plot = [ax.plot([0,0],[0,0],[0,0], c='b')[0] for _ in skeleton]
|
||||
|
||||
ax.set_xlabel('X')
|
||||
ax.set_ylabel('Y')
|
||||
ax.set_zlabel('Z')
|
||||
ax.set_xlim(-0.6, 0.4)
|
||||
ax.set_ylim(1.2, 2.2)
|
||||
ax.set_zlim(-0.5, 1.1)
|
||||
ax.view_init(elev=20, azim=-60)
|
||||
|
||||
i = 0
|
||||
|
||||
for points3Dkey in points3DList:
|
||||
points3D = points3DList[points3Dkey]
|
||||
print("3D points:\n", points3D)
|
||||
|
||||
# --- Wizualizacja 3D ---d
|
||||
X = points3D[:,0] - 0.25
|
||||
Z = -points3D[:,1] + 0.5
|
||||
Y = points3D[:,2]
|
||||
|
||||
points_plot._offsets3d = (X, Y, Z)
|
||||
|
||||
# Aktualizacja linii (szkielet)
|
||||
for idx, (i, j) in enumerate(skeleton):
|
||||
lines_plot[idx].set_data([X[i], X[j]], [Y[i], Y[j]])
|
||||
lines_plot[idx].set_3d_properties([Z[i], Z[j]])
|
||||
|
||||
fig.canvas.draw()
|
||||
fig.canvas.flush_events()
|
||||
plt.pause(0.01)
|
||||
Reference in New Issue
Block a user