pose: [N, 17*3]
(pose, mean_and_std=None,res_w_h=None, which='zero_center',scale = None,two_d = False)
| 73 | |
| 74 | return pose |
| 75 | def denormalize_pose_cuda(pose, mean_and_std=None,res_w_h=None, which='zero_center',scale = None,two_d = False): |
| 76 | """ |
| 77 | pose: [N, 17*3] |
| 78 | """ |
| 79 | batch_size = pose.shape[0] # pose: float32 [N, 17, 3] |
| 80 | if two_d: |
| 81 | pose = pose.view((batch_size, -1, 2)) |
| 82 | else: |
| 83 | pose = pose.view((batch_size, -1, 3)) |
| 84 | if which == 'zero_center': |
| 85 | output = pose * mean_and_std['std'] + mean_and_std['mean'] |
| 86 | return output |
| 87 | elif which == 'scale': |
| 88 | for idx in range(batch_size): |
| 89 | res_idx = res_w_h[idx].split(' ') |
| 90 | res_w, res_h = int(res_idx[0]), int(res_idx[1]) |
| 91 | pose[idx, :, :2] = (pose[idx, :, :2] + torch.tensor([1, res_h / res_w]).float().cuda()) * res_w / 2 |
| 92 | pose[idx, :, 2:] = pose[idx, :, 2:] * res_w / 2 |
| 93 | return pose |
| 94 | elif which == 'scale_s': |
| 95 | #scale = scale.transpose(1,0) |
| 96 | pose[:,:,0] = pose[:,:,0] * (scale[0].view(-1,1)) |
| 97 | pose[:,:,1] = pose[:,:,1] * (scale[1].view(-1,1)) |
| 98 | if not two_d: |
| 99 | pose[:,:,2] = pose[:,:,2] * (scale[2].view(-1,1)) |
| 100 | return pose |
| 101 | elif which == 'scale_t': |
| 102 | if not mean_and_std: |
| 103 | mean_and_std = 1 |
| 104 | pose = pose / 2 |
| 105 | pose[:,:,0] = (pose[:,:,0]+0.5*mean_and_std) * (scale[0].view(-1,1)) |
| 106 | pose[:,:,1] = (pose[:,:,1]+0.5*mean_and_std) * (scale[1].view(-1,1)) |
| 107 | if not two_d: |
| 108 | pose[:,:,2] = pose[:,:,2] * (scale[2].view(-1,1)) |
| 109 | return pose |
| 110 | |
| 111 | else: |
| 112 | assert 0, 'only support zero_center or scale normalization' |
| 113 | |
| 114 | def uvd_to_cam(uvd_jts, trans_inv, intrinsic_param, joint_root, depth_factor, return_relative=True): |
| 115 | assert uvd_jts.dim() == 3 and uvd_jts.shape[2] == 3, uvd_jts.shape |