(root_pose, body_pose, lhand_pose, rhand_pose, jaw_pose, shape, expr, cam_trans, mode='test', zero_global=False, mesh=False)
| 105 | return frames |
| 106 | |
| 107 | def get_coord(root_pose, body_pose, lhand_pose, rhand_pose, jaw_pose, shape, expr, cam_trans, mode='test', zero_global=False, mesh=False): |
| 108 | batch_size = root_pose.shape[0] |
| 109 | zero_pose = torch.zeros((1, 3)).float().cuda().repeat(batch_size, 1) # eye poses |
| 110 | if not zero_global: |
| 111 | output = smplx_layer(betas=shape, body_pose=body_pose, global_orient=root_pose, right_hand_pose=rhand_pose, |
| 112 | left_hand_pose=lhand_pose, jaw_pose=jaw_pose, leye_pose=zero_pose, |
| 113 | reye_pose=zero_pose, expression=expr) |
| 114 | else: |
| 115 | raise ValueError |
| 116 | output = smplx_layer(betas=shape, body_pose=body_pose, global_orient=zero_pose, right_hand_pose=rhand_pose, |
| 117 | left_hand_pose=lhand_pose, jaw_pose=zero_pose, leye_pose=zero_pose, |
| 118 | reye_pose=zero_pose, expression=expr) |
| 119 | |
| 120 | # camera-centered 3D coordinate |
| 121 | mesh_cam = output.vertices |
| 122 | joint_cam = output.joints[:, smpl_x.joint_idx, :] |
| 123 | |
| 124 | # project 3D coordinates to 2D space |
| 125 | x = (joint_cam[:, :, 0] + cam_trans[:, None, 0]) / (joint_cam[:, :, 2] + cam_trans[:, None, 2] + 1e-4) * \ |
| 126 | focal[0] + princpt[0] |
| 127 | y = (joint_cam[:, :, 1] + cam_trans[:, None, 1]) / (joint_cam[:, :, 2] + cam_trans[:, None, 2] + 1e-4) * \ |
| 128 | focal[1] + princpt[1] |
| 129 | x = x / input_body_shape[1] * output_hm_shape[2] |
| 130 | y = y / input_body_shape[0] * output_hm_shape[1] |
| 131 | joint_proj = torch.stack((x, y), 2) |
| 132 | |
| 133 | # mesh |
| 134 | if mesh: |
| 135 | tx = (mesh_cam[:, :, 0] + cam_trans[:, None, 0]) / (mesh_cam[:, :, 2] + cam_trans[:, None, 2] + 1e-4) * \ |
| 136 | focal[0] + princpt[0] |
| 137 | ty = (mesh_cam[:, :, 1] + cam_trans[:, None, 1]) / (mesh_cam[:, :, 2] + cam_trans[:, None, 2] + 1e-4) * \ |
| 138 | focal[1] + princpt[1] |
| 139 | tx = tx / input_body_shape[1] * output_hm_shape[2] |
| 140 | ty = ty / input_body_shape[0] * output_hm_shape[1] |
| 141 | mesh_proj = torch.stack((tx, ty), 2) |
| 142 | root_cam = joint_cam[:, smpl_x.root_joint_idx, None, :] |
| 143 | joint_cam = joint_cam - root_cam |
| 144 | render_mesh_cam = mesh_cam + cam_trans[:, None, :] # for rendering |
| 145 | |
| 146 | return render_mesh_cam |
| 147 | else: |
| 148 | return joint_proj |
| 149 | |
| 150 | def render(img, mesh, face, cam_param): |
| 151 | # mesh |
no outgoing calls
no test coverage detected