MCPcopy Create free account
hub / github.com/Xuehao-Gao/GUESS / plot_3d_motion

Function plot_3d_motion

mld/data/humanml/utils/plot_script.py:32–131  ·  view source on GitHub ↗
(save_path, joints, title, figsize=(3, 3), fps=120, radius=3, kinematic_tree=skeleton)

Source from the content-addressed store, hash-verified

30
31
32def plot_3d_motion(save_path, joints, title, figsize=(3, 3), fps=120, radius=3, kinematic_tree=skeleton):
33 matplotlib.use('Agg')
34
35 # title_sp = title.split(' ')
36 # if len(title_sp) > 20:
37 # title = '\n'.join([' '.join(title_sp[:10]), ' '.join(title_sp[10:20]), ' '.join(title_sp[20:])])
38 # elif len(title_sp) > 10:
39 # title = '\n'.join([' '.join(title_sp[:10]), ' '.join(title_sp[10:])])
40 title = '\n'.join(wrap(title, 20))
41
42 def init():
43 ax.set_xlim3d([-radius / 2, radius / 2])
44 ax.set_ylim3d([0, radius])
45 ax.set_zlim3d([-radius / 3., radius * 2 / 3.])
46 # print(title)
47 fig.suptitle(title, fontsize=10)
48 ax.grid(b=False)
49
50 def plot_xzPlane(minx, maxx, miny, minz, maxz):
51 # Plot a plane XZ
52 verts = [
53 [minx, miny, minz],
54 [minx, miny, maxz],
55 [maxx, miny, maxz],
56 [maxx, miny, minz]
57 ]
58 xz_plane = Poly3DCollection([verts])
59 xz_plane.set_facecolor((0.5, 0.5, 0.5, 0.5))
60 ax.add_collection3d(xz_plane)
61
62 # return ax
63
64 # (seq_len, joints_num, 3)
65 data = joints.copy().reshape(len(joints), -1, 3)
66 fig = plt.figure(figsize=figsize)
67 plt.tight_layout()
68 ax = p3.Axes3D(fig)
69 init()
70 MINS = data.min(axis=0).min(axis=0)
71 MAXS = data.max(axis=0).max(axis=0)
72 # colors = ['red', 'blue', 'black', 'red', 'blue',
73 # 'darkblue', 'darkblue', 'darkblue', 'darkblue', 'darkblue',
74 # 'darkred', 'darkred', 'darkred', 'darkred', 'darkred']
75 colors = ["#DD5A37", "#D69E00", "#B75A39", "#DD5A37", "#D69E00",
76 "#FF6D00", "#FF6D00", "#FF6D00", "#FF6D00", "#FF6D00",
77 "#DDB50E", "#DDB50E", "#DDB50E", "#DDB50E", "#DDB50E", ]
78
79 frame_number = data.shape[0]
80 # print(dataset.shape)
81
82 height_offset = MINS[1]
83 data[:, :, 1] -= height_offset
84 trajec = data[:, 0, [0, 2]]
85
86 data[..., 0] -= data[:, 0:1, 0]
87 data[..., 2] -= data[:, 0:1, 2]
88
89 # print(trajec.shape)

Callers 1

mainFunction · 0.90

Calls 2

initFunction · 0.85
saveMethod · 0.80

Tested by

no test coverage detected