Convert box3d in camera coordinates to bbox in image coordinates. Args: box3d (np.ndarray, shape=[N, 7]): Boxes in camera coordinate. P2 (np.array, shape=[4, 4]): Intrinsics of Camera2. Returns: np.ndarray, shape=[N, 4]: Boxes 2d in image coordinates.
(box3d, P2)
| 309 | |
| 310 | |
| 311 | def box3d_to_bbox(box3d, P2): |
| 312 | """Convert box3d in camera coordinates to bbox in image coordinates. |
| 313 | |
| 314 | Args: |
| 315 | box3d (np.ndarray, shape=[N, 7]): Boxes in camera coordinate. |
| 316 | P2 (np.array, shape=[4, 4]): Intrinsics of Camera2. |
| 317 | |
| 318 | Returns: |
| 319 | np.ndarray, shape=[N, 4]: Boxes 2d in image coordinates. |
| 320 | """ |
| 321 | box_corners = center_to_corner_box3d(box3d[:, :3], |
| 322 | box3d[:, 3:6], |
| 323 | box3d[:, 6], [0.5, 1.0, 0.5], |
| 324 | axis=1) |
| 325 | box_corners_in_image = points_cam2img(box_corners, P2) |
| 326 | # box_corners_in_image: [N, 8, 2] |
| 327 | minxy = np.min(box_corners_in_image, axis=1) |
| 328 | maxxy = np.max(box_corners_in_image, axis=1) |
| 329 | bbox = np.concatenate([minxy, maxxy], axis=1) |
| 330 | return bbox |
| 331 | |
| 332 | |
| 333 | def corner_to_surfaces_3d(corners): |
nothing calls this directly
no test coverage detected