(args, figsize=(10, 10), fps=120, radius=4)
| 10 | |
| 11 | |
| 12 | def plot_3d_motion(args, figsize=(10, 10), fps=120, radius=4): |
| 13 | matplotlib.use('Agg') |
| 14 | |
| 15 | joints, out_name, title = args |
| 16 | |
| 17 | title_sp = title.split(' ') |
| 18 | if len(title_sp) > 20: |
| 19 | title = '\n'.join([' '.join(title_sp[:10]), ' '.join(title_sp[10:20]), ' '.join(title_sp[20:])]) |
| 20 | elif len(title_sp) > 10: |
| 21 | title = '\n'.join([' '.join(title_sp[:10]), ' '.join(title_sp[10:])]) |
| 22 | |
| 23 | data = joints.copy().reshape(len(joints), -1, 3) |
| 24 | |
| 25 | nb_joints = joints.shape[1] |
| 26 | smpl_kinetic_chain = [ |
| 27 | [0, 11, 12, 13, 14, 15], [0, 16, 17, 18, 19, 20], [0, 1, 2, 3, 4], |
| 28 | [3, 5, 6, 7], [3, 8, 9, 10] |
| 29 | ] if nb_joints == 21 else [[0, 2, 5, 8, 11], [0, 1, 4, 7, 10], |
| 30 | [0, 3, 6, 9, 12, 15], [9, 14, 17, 19, 21], |
| 31 | [9, 13, 16, 18, 20]] |
| 32 | limits = 1000 if nb_joints == 21 else 2 |
| 33 | |
| 34 | MINS = data.min(axis=0).min(axis=0) |
| 35 | MAXS = data.max(axis=0).max(axis=0) |
| 36 | |
| 37 | colors = [ |
| 38 | 'red', 'blue', 'black', 'red', 'blue', 'darkblue', 'darkblue', |
| 39 | 'darkblue', 'darkblue', 'darkblue', 'darkred', 'darkred', 'darkred', |
| 40 | 'darkred', 'darkred' |
| 41 | ] |
| 42 | frame_number = data.shape[0] |
| 43 | # print(data.shape) |
| 44 | |
| 45 | height_offset = MINS[1] |
| 46 | data[:, :, 1] -= height_offset |
| 47 | trajec = data[:, 0, [0, 2]] |
| 48 | |
| 49 | data[..., 0] -= data[:, 0:1, 0] |
| 50 | data[..., 2] -= data[:, 0:1, 2] |
| 51 | |
| 52 | def update(index): |
| 53 | def init(): |
| 54 | ax.set_xlim3d([-radius / 2, radius / 2]) |
| 55 | ax.set_ylim3d([0, radius]) |
| 56 | ax.set_zlim3d([0, radius]) |
| 57 | ax.grid(b=False) |
| 58 | |
| 59 | def plot_xzPlane(minx, maxx, miny, minz, maxz): |
| 60 | ## Plot a plane XZ |
| 61 | verts = [[minx, miny, minz], [minx, miny, maxz], |
| 62 | [maxx, miny, maxz], [maxx, miny, minz]] |
| 63 | xz_plane = Poly3DCollection([verts]) |
| 64 | xz_plane.set_facecolor((0.5, 0.5, 0.5, 0.5)) |
| 65 | ax.add_collection3d(xz_plane) |
| 66 | |
| 67 | fig = plt.figure(figsize=(480 / 96., 320 / 96.), |
| 68 | dpi=96) if nb_joints == 21 else plt.figure( |
| 69 | figsize=(10, 10), dpi=96) |
no test coverage detected