(self, results)
| 1150 | pass |
| 1151 | |
| 1152 | def __call__(self, results): |
| 1153 | r = results['rotation'] |
| 1154 | if r == 0.0: |
| 1155 | return results |
| 1156 | img = results['img'] |
| 1157 | |
| 1158 | # img before affine |
| 1159 | (h, w) = img.shape[:2] |
| 1160 | (cX, cY) = (w // 2, h // 2) |
| 1161 | M = cv2.getRotationMatrix2D((cX, cY), r, 1.0) |
| 1162 | cos = np.abs(M[0, 0]) |
| 1163 | sin = np.abs(M[0, 1]) |
| 1164 | # compute the new bounding dimensions of the image |
| 1165 | nW = int((h * sin) + (w * cos)) |
| 1166 | nH = int((h * cos) + (w * sin)) |
| 1167 | # adjust the rotation matrix to take into account translation |
| 1168 | M[0, 2] += (nW / 2) - cX |
| 1169 | M[1, 2] += (nH / 2) - cY |
| 1170 | # perform the actual rotation and return the image |
| 1171 | img = cv2.warpAffine(img, M, (nW, nH)) |
| 1172 | |
| 1173 | results['img'] = img |
| 1174 | |
| 1175 | c = results['center'] |
| 1176 | c = np.dot(M[:2, :2], c) + M[:2, 2] |
| 1177 | results['center'] = c |
| 1178 | |
| 1179 | if 'keypoints2d' in results: |
| 1180 | keypoints2d = results['keypoints2d'].copy() |
| 1181 | keypoints2d[:, :2] = (np.dot(keypoints2d[:, :2], M[:2, :2].T) + |
| 1182 | M[:2, 2] + 1).astype(np.int) |
| 1183 | results['keypoints2d'] = keypoints2d |
| 1184 | |
| 1185 | if 'keypoints3d' in results: |
| 1186 | keypoints3d = results['keypoints3d'].copy() |
| 1187 | keypoints3d[:, :3] = _rotate_joints_3d(keypoints3d[:, :3], r) |
| 1188 | results['keypoints3d'] = keypoints3d |
| 1189 | |
| 1190 | if 'smpl_body_pose' in results: |
| 1191 | global_orient = results['smpl_global_orient'].copy() |
| 1192 | body_pose = results['smpl_body_pose'].copy().reshape((-1)) |
| 1193 | pose = np.concatenate((global_orient, body_pose), axis=-1) |
| 1194 | pose = _rotate_smpl_pose(pose, r) |
| 1195 | results['smpl_global_orient'] = pose[:3] |
| 1196 | results['smpl_body_pose'] = pose[3:].reshape((-1, 3)) |
| 1197 | |
| 1198 | if 'smplx_global_orient' in results: |
| 1199 | global_orient = results['smplx_global_orient'].copy() |
| 1200 | global_orient = _rotate_smpl_pose(global_orient, r) |
| 1201 | results['smplx_global_orient'] = global_orient |
| 1202 | |
| 1203 | results['rotation'] = 0.0 |
| 1204 | results['ori_rotation'] = r |
| 1205 | return results |
| 1206 | |
| 1207 | |
| 1208 | @PIPELINES.register_module() |
nothing calls this directly
no test coverage detected