(self, dataset, folder_list)
| 55 | print('Testing on {} frames'.format(self.generator.num_frames())) |
| 56 | |
| 57 | def prepare_data(self, dataset, folder_list): |
| 58 | for subject in folder_list: |
| 59 | for action in dataset[subject].keys(): |
| 60 | anim = dataset[subject][action] |
| 61 | |
| 62 | positions_3d = [] |
| 63 | for cam in anim['cameras']: |
| 64 | pos_3d = world_to_camera(anim['positions'], R=cam['orientation'], t=cam['translation']) |
| 65 | pos_3d[:, 1:] -= pos_3d[:, :1] |
| 66 | |
| 67 | positions_3d.append(pos_3d) |
| 68 | anim['positions_3d'] = positions_3d |
| 69 | |
| 70 | keypoints = np.load(self.root_path + 'data_2d_' + self.data_type + '_' + self.keypoints_name + '.npz',allow_pickle=True) |
| 71 | keypoints_GT = np.load(self.root_path + 'data_2d_' + self.data_type + '_' + 'gt' + '.npz',allow_pickle=True) |
| 72 | |
| 73 | keypoints_symmetry = keypoints['metadata'].item()['keypoints_symmetry'] |
| 74 | |
| 75 | self.kps_left, self.kps_right = list(keypoints_symmetry[0]), list(keypoints_symmetry[1]) |
| 76 | self.joints_left, self.joints_right = list(dataset.skeleton().joints_left()), list( |
| 77 | dataset.skeleton().joints_right()) |
| 78 | |
| 79 | keypoints = keypoints['positions_2d'].item() |
| 80 | keypoints_GT = keypoints_GT['positions_2d'].item() |
| 81 | |
| 82 | for subject in folder_list: |
| 83 | assert subject in keypoints, 'Subject {} is missing from the 2D detections dataset'.format(subject) |
| 84 | for action in dataset[subject].keys(): |
| 85 | assert action in keypoints[ |
| 86 | subject], 'Action {} of subject {} is missing from the 2D detections dataset'.format(action, |
| 87 | subject) |
| 88 | for cam_idx in range(len(keypoints[subject][action])): |
| 89 | mocap_length = dataset[subject][action]['positions_3d'][cam_idx].shape[0] |
| 90 | assert keypoints[subject][action][cam_idx].shape[0] >= mocap_length |
| 91 | |
| 92 | if keypoints[subject][action][cam_idx].shape[0] > mocap_length: |
| 93 | keypoints[subject][action][cam_idx] = keypoints[subject][action][cam_idx][:mocap_length] |
| 94 | keypoints_GT[subject][action][cam_idx] = keypoints_GT[subject][action][cam_idx][:mocap_length] |
| 95 | |
| 96 | |
| 97 | for subject in folder_list: |
| 98 | for action in keypoints_GT[subject]: |
| 99 | for cam_idx, item in enumerate(keypoints_GT[subject][action]): |
| 100 | kps = keypoints[subject][action][cam_idx] |
| 101 | kps_GT = keypoints_GT[subject][action][cam_idx] |
| 102 | |
| 103 | cam = dataset.cameras()[subject][cam_idx] |
| 104 | |
| 105 | if self.crop_uv == 0: |
| 106 | kps[..., :2] = normalize_screen_coordinates(kps[..., :2], w=cam['res_w'], h=cam['res_h']) |
| 107 | kps_GT[..., :2] = normalize_screen_coordinates(kps_GT[..., :2], w=cam['res_w'], h=cam['res_h']) |
| 108 | |
| 109 | keypoints[subject][action][cam_idx] = kps |
| 110 | keypoints_GT[subject][action][cam_idx] = kps_GT |
| 111 | |
| 112 | return keypoints, keypoints_GT |
| 113 | |
| 114 | def fetch(self, dataset, subjects, subset=1, parse_3d_poses=True): |
no test coverage detected