(positions, target_offset)
| 11 | |
| 12 | # positions (batch, joint_num, 3) |
| 13 | def uniform_skeleton(positions, target_offset): |
| 14 | src_skel = Skeleton(n_raw_offsets, kinematic_chain, 'cpu') |
| 15 | src_offset = src_skel.get_offsets_joints(torch.from_numpy(positions[0])) |
| 16 | src_offset = src_offset.numpy() |
| 17 | tgt_offset = target_offset.numpy() |
| 18 | # print(src_offset) |
| 19 | # print(tgt_offset) |
| 20 | '''Calculate Scale Ratio as the ratio of legs''' |
| 21 | src_leg_len = np.abs(src_offset[l_idx1]).max() + np.abs(src_offset[l_idx2]).max() |
| 22 | tgt_leg_len = np.abs(tgt_offset[l_idx1]).max() + np.abs(tgt_offset[l_idx2]).max() |
| 23 | |
| 24 | scale_rt = tgt_leg_len / src_leg_len |
| 25 | # print(scale_rt) |
| 26 | src_root_pos = positions[:, 0] |
| 27 | tgt_root_pos = src_root_pos * scale_rt |
| 28 | |
| 29 | '''Inverse Kinematics''' |
| 30 | quat_params = src_skel.inverse_kinematics_np(positions, face_joint_indx) |
| 31 | # print(quat_params.shape) |
| 32 | |
| 33 | '''Forward Kinematics''' |
| 34 | src_skel.set_offset(target_offset) |
| 35 | new_joints = src_skel.forward_kinematics_np(quat_params, tgt_root_pos) |
| 36 | return new_joints |
| 37 | |
| 38 | |
| 39 | def extract_features(positions, feet_thre, n_raw_offsets, kinematic_chain, face_joint_indx, fid_r, fid_l): |
no test coverage detected