MCPcopy Create free account
hub / github.com/InternRobotics/EmbodiedScan / box3d_to_bbox

Function box3d_to_bbox

embodiedscan/structures/ops/box_np_ops.py:311–330  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

309
310
311def 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
333def corner_to_surfaces_3d(corners):

Callers

nothing calls this directly

Calls 2

points_cam2imgFunction · 0.90
center_to_corner_box3dFunction · 0.85

Tested by

no test coverage detected