MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / plot_3d_motion

Function plot_3d_motion

mogen/utils/plot_utils.py:107–204  ·  view source on GitHub ↗
(save_path,
                   motion_length,
                   kinematic_tree,
                   joints,
                   title,
                   figsize=(10, 10),
                   fps=120,
                   radius=4)

Source from the content-addressed store, hash-verified

105
106
107def plot_3d_motion(save_path,
108 motion_length,
109 kinematic_tree,
110 joints,
111 title,
112 figsize=(10, 10),
113 fps=120,
114 radius=4):
115 matplotlib.use('Agg')
116
117 title_list = []
118 for idx, t in enumerate(title):
119 title_sp = t.split(' ')
120 new_t = t
121 if len(title_sp) > 20:
122 new_t = '\n'.join([
123 ' '.join(title_sp[:10]), ' '.join(title_sp[10:20]),
124 ' '.join(title_sp[20:])
125 ])
126 elif len(title_sp) > 10:
127 new_t = '\n'.join(
128 [' '.join(title_sp[:10]), ' '.join(title_sp[10:])])
129 for i in range(motion_length[idx]):
130 title_list.append(new_t)
131
132 def init():
133 ax.set_xlim3d([-radius / 4, radius / 4])
134 ax.set_ylim3d([0, radius / 2])
135 ax.set_zlim3d([0, radius / 2])
136 ax.grid(b=False)
137
138 def plot_xzPlane(minx, maxx, miny, minz, maxz):
139 verts = [[minx, miny, minz], [minx, miny, maxz], [maxx, miny, maxz],
140 [maxx, miny, minz]]
141 xz_plane = Poly3DCollection([verts])
142 xz_plane.set_facecolor((0.5, 0.5, 0.5, 0.5))
143 ax.add_collection3d(xz_plane)
144
145 # (seq_len, joints_num, 3)
146 data = joints.copy().reshape(len(joints), -1, 3)
147 fig = plt.figure(figsize=figsize)
148 ax = p3.Axes3D(fig)
149 init()
150 MINS = data.min(axis=0).min(axis=0)
151 MAXS = data.max(axis=0).max(axis=0)
152 colors = [
153 'red', 'blue', 'black', 'red', 'blue', 'darkblue', 'darkblue',
154 'darkblue', 'darkblue', 'darkblue', 'darkred', 'darkred', 'darkred',
155 'darkred', 'darkred'
156 ]
157 frame_number = data.shape[0]
158
159 height_offset = MINS[1]
160 data[:, :, 1] -= height_offset
161 trajec = data[:, 0, [0, 2]]
162
163 data[..., 0] -= data[:, 0:1, 0]
164 data[..., 2] -= data[:, 0:1, 2]

Callers 1

plot_t2mFunction · 0.90

Calls 1

initFunction · 0.85

Tested by

no test coverage detected