(self, dataset, folder_list)
| 49 | print('Testing on {} frames'.format(self.generator.num_frames())) |
| 50 | |
| 51 | def prepare_data(self, dataset, folder_list): |
| 52 | for subject in folder_list: |
| 53 | for action in dataset[subject].keys(): |
| 54 | anim = dataset[subject][action] |
| 55 | |
| 56 | positions_3d = [] |
| 57 | for i in range(len(anim['positions'])): |
| 58 | pos_3d = anim['positions'][i] |
| 59 | |
| 60 | pos_3d[:, 1:] -= pos_3d[:, :1] |
| 61 | |
| 62 | positions_3d.append(pos_3d) |
| 63 | anim['positions_3d'] = positions_3d |
| 64 | |
| 65 | keypoints_pth = self.root_path + 'data_2d_' + self.data_type + '.npz' |
| 66 | |
| 67 | keypoints = np.load(keypoints_pth, allow_pickle=True) |
| 68 | keypoints_GT = np.load(keypoints_pth,allow_pickle=True) |
| 69 | |
| 70 | self.kps_left, self.kps_right = [4,5,6,11,12,13], [1,2,3,14,15,16] |
| 71 | self.joints_left, self.joints_right = [4,5,6,11,12,13], [1,2,3,14,15,16] |
| 72 | |
| 73 | keypoints = keypoints['positions_2d'].item() |
| 74 | keypoints_GT = keypoints_GT['positions_2d'].item() |
| 75 | |
| 76 | for subject in folder_list: |
| 77 | assert subject in keypoints, 'Subject {} is missing from the 2D detections dataset'.format(subject) |
| 78 | for action in dataset[subject].keys(): |
| 79 | assert action in keypoints[ |
| 80 | subject], 'Action {} of subject {} is missing from the 2D detections dataset'.format(action, |
| 81 | subject) |
| 82 | for cam_idx in range(len(keypoints[subject][action])): |
| 83 | mocap_length = dataset[subject][action]['positions_3d'][cam_idx].shape[0] |
| 84 | |
| 85 | assert keypoints[subject][action][cam_idx].shape[0] >= mocap_length |
| 86 | |
| 87 | if keypoints[subject][action][cam_idx].shape[0] > mocap_length: |
| 88 | keypoints[subject][action][cam_idx] = keypoints[subject][action][cam_idx][:mocap_length] |
| 89 | keypoints_GT[subject][action][cam_idx] = keypoints_GT[subject][action][cam_idx][:mocap_length] |
| 90 | |
| 91 | for subject in keypoints_GT.keys(): |
| 92 | for action in keypoints_GT[subject]: |
| 93 | for cam_idx, item in enumerate(keypoints_GT[subject][action]): |
| 94 | kps = keypoints[subject][action][cam_idx] |
| 95 | kps_GT = keypoints_GT[subject][action][cam_idx] |
| 96 | |
| 97 | if subject == 'TS5' or subject == 'TS6': |
| 98 | res_w = 1920 |
| 99 | res_h = 1080 |
| 100 | else: |
| 101 | res_w = 2048 |
| 102 | res_h = 2048 |
| 103 | |
| 104 | if self.crop_uv == 0: |
| 105 | kps[..., :2] = normalize_screen_coordinates(kps[..., :2], w=res_w, h=res_h) |
| 106 | kps_GT[..., :2] = normalize_screen_coordinates(kps_GT[..., :2], w=res_w, h=res_h) |
| 107 | |
| 108 | keypoints[subject][action][cam_idx] = kps |
no test coverage detected