Convert vertices from the world coordinate to camera coordinate. Args: verts ([np.ndarray]): The vertices in the world coordinate. The shape is (frame,num_person,6890,3), (frame,6890,3), or (6890,3). pred_cams ([np.ndarray]): Camera parameters estimated b
(verts,
pred_cams,
bboxes_xy,
focal_length=5000.,
bbox_scale_factor=1.25,
bbox_format='xyxy')
| 263 | |
| 264 | |
| 265 | def convert_verts_to_cam_coord(verts, |
| 266 | pred_cams, |
| 267 | bboxes_xy, |
| 268 | focal_length=5000., |
| 269 | bbox_scale_factor=1.25, |
| 270 | bbox_format='xyxy'): |
| 271 | """Convert vertices from the world coordinate to camera coordinate. |
| 272 | |
| 273 | Args: |
| 274 | verts ([np.ndarray]): The vertices in the world coordinate. |
| 275 | The shape is (frame,num_person,6890,3), (frame,6890,3), |
| 276 | or (6890,3). |
| 277 | pred_cams ([np.ndarray]): Camera parameters estimated by HMR or SPIN. |
| 278 | The shape is (frame,num_person,3), (frame,3), or (3,). |
| 279 | bboxes_xy ([np.ndarray]): (frame, num_person, 4|5), (frame, 4|5), |
| 280 | or (4|5,) |
| 281 | focal_length ([float],optional): Defined same as your training. |
| 282 | bbox_scale_factor (float): scale factor for expanding the bbox. |
| 283 | bbox_format (Literal['xyxy', 'xywh'] ): 'xyxy' means the left-up point |
| 284 | and right-bottomn point of the bbox. |
| 285 | 'xywh' means the left-up point and the width and height of the |
| 286 | bbox. |
| 287 | Returns: |
| 288 | np.ndarray: The vertices in the camera coordinate. |
| 289 | The shape is (frame,num_person,6890,3) or (frame,6890,3). |
| 290 | np.ndarray: The intrinsic parameters of the pred_cam. |
| 291 | The shape is (num_frame, 3, 3). |
| 292 | """ |
| 293 | K0 = get_default_hmr_intrinsic(focal_length=focal_length, |
| 294 | det_height=224, |
| 295 | det_width=224) |
| 296 | K1 = convert_bbox_to_intrinsic(bboxes_xy, |
| 297 | bbox_scale_factor=bbox_scale_factor, |
| 298 | bbox_format=bbox_format) |
| 299 | # K1K0(RX+T)-> K0(K0_inv K1K0) |
| 300 | Ks = np.linalg.inv(K0) @ K1 @ K0 |
| 301 | # convert vertices from world to camera |
| 302 | cam_trans = np.concatenate([ |
| 303 | pred_cams[..., [1]], pred_cams[..., [2]], 2 * focal_length / |
| 304 | (224 * pred_cams[..., [0]] + 1e-9) |
| 305 | ], -1) |
| 306 | verts = verts + cam_trans[..., None, :] |
| 307 | if verts.ndim == 4: |
| 308 | verts = np.einsum('fnij,fnkj->fnki', Ks, verts) |
| 309 | elif verts.ndim == 3: |
| 310 | verts = np.einsum('fij,fkj->fki', Ks, verts) |
| 311 | elif verts.ndim == 2: |
| 312 | verts = np.einsum('fij,fkj->fki', Ks, verts[None]) |
| 313 | return verts, K0 |
| 314 | |
| 315 | |
| 316 | def smooth_process(x, |
nothing calls this directly
no test coverage detected