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

Function plot_siamese_3d_motion

mogen/utils/plot_utils.py:207–309  ·  view source on GitHub ↗
(save_path,
                           kinematic_tree,
                           mp_joints,
                           title,
                           figsize=(10, 10),
                           fps=120,
                           radius=4)

Source from the content-addressed store, hash-verified

205
206
207def plot_siamese_3d_motion(save_path,
208 kinematic_tree,
209 mp_joints,
210 title,
211 figsize=(10, 10),
212 fps=120,
213 radius=4):
214 matplotlib.use('Agg')
215
216 title_sp = title.split(' ')
217 if len(title_sp) > 20:
218 title = '\n'.join([
219 ' '.join(title_sp[:10]), ' '.join(title_sp[10:20]),
220 ' '.join(title_sp[20:])
221 ])
222 elif len(title_sp) > 10:
223 title = '\n'.join([' '.join(title_sp[:10]), ' '.join(title_sp[10:])])
224
225 def init():
226 ax.set_xlim3d([-radius / 4, radius / 4])
227 ax.set_ylim3d([0, radius / 2])
228 ax.set_zlim3d([0, radius / 2])
229 # print(title)
230 fig.suptitle(title, fontsize=20)
231 ax.grid(b=False)
232
233 def plot_xzPlane(minx, maxx, miny, minz, maxz):
234 # Plot a plane XZ
235 verts = [[minx, miny, minz], [minx, miny, maxz], [maxx, miny, maxz],
236 [maxx, miny, minz]]
237 xz_plane = Poly3DCollection([verts])
238 xz_plane.set_facecolor((0.5, 0.5, 0.5, 0.5))
239 ax.add_collection3d(xz_plane)
240
241 fig = plt.figure(figsize=figsize)
242 ax = p3.Axes3D(fig)
243 init()
244
245 mp_data = []
246 frame_number = min([data.shape[0] for data in mp_joints])
247 print(frame_number)
248
249 colors = [
250 'red', 'green', 'black', 'red', 'blue', 'darkblue', 'darkblue',
251 'darkblue', 'darkblue', 'darkblue', 'darkred', 'darkred', 'darkred',
252 'darkred', 'darkred'
253 ]
254
255 mp_offset = list(range(-len(mp_joints) // 2, len(mp_joints) // 2, 1))
256 mp_colors = [[colors[i]] * 15 for i in range(len(mp_offset))]
257
258 for i, joints in enumerate(mp_joints):
259
260 # (seq_len, joints_num, 3)
261 data = joints.copy().reshape(len(joints), -1, 3)
262
263 MINS = data.min(axis=0).min(axis=0)
264 MAXS = data.max(axis=0).max(axis=0)

Callers 1

plot_interhumanFunction · 0.90

Calls 1

initFunction · 0.85

Tested by

no test coverage detected