Perform orthographic projection of 3D points using the camera parameters, return projected 2D points in image plane. Notes: batch size: B point number: N Args: points_3d (Tensor([B, N, 3])): 3D points. camera (Tensor([B, 3])): camera parameters with the
(points_3d, pred_cam, focal_length, camera_center)
| 391 | return keypoints_2d |
| 392 | |
| 393 | def project_points_new(points_3d, pred_cam, focal_length, camera_center): |
| 394 | """Perform orthographic projection of 3D points using the camera |
| 395 | parameters, return projected 2D points in image plane. |
| 396 | |
| 397 | Notes: |
| 398 | batch size: B |
| 399 | point number: N |
| 400 | Args: |
| 401 | points_3d (Tensor([B, N, 3])): 3D points. |
| 402 | camera (Tensor([B, 3])): camera parameters with the |
| 403 | 3 channel as (scale, translation_x, translation_y) |
| 404 | Returns: |
| 405 | points_2d (Tensor([B, N, 2])): projected 2D points |
| 406 | in image space. |
| 407 | """ |
| 408 | batch_size = points_3d.shape[0] |
| 409 | device = points_3d.device |
| 410 | |
| 411 | (s, tx, ty) = (pred_cam[:, 0] + 1e-9), pred_cam[:, 1], pred_cam[:, 2] |
| 412 | depth, dx, dy = 1./s, tx/s, ty/s |
| 413 | cam_t = torch.stack([dx, dy, depth], 1) |
| 414 | |
| 415 | # cam_t = torch.stack([ |
| 416 | # camera[:, 1], camera[:, 2], 2 * focal_length / |
| 417 | # (img_res * camera[:, 0] + 1e-9) |
| 418 | # ], |
| 419 | # dim=-1) |
| 420 | rot_t = torch.eye(3, device=device, |
| 421 | dtype=points_3d.dtype).unsqueeze(0).expand( |
| 422 | batch_size, -1, -1) |
| 423 | keypoints_2d = perspective_projection(points_3d, |
| 424 | rotation=rot_t, |
| 425 | translation=cam_t, |
| 426 | focal_length=focal_length, |
| 427 | camera_center=camera_center) |
| 428 | return keypoints_2d |
| 429 | |
| 430 | |
| 431 |
no test coverage detected