Get frustum corners in camera coordinates. Args: bbox_image (list[int]): box in image coordinates. C (np.ndarray): Intrinsics. near_clip (float, optional): Nearest distance of frustum. Defaults to 0.001. far_clip (float, optional): Farthest distance o
(bbox_image, C, near_clip=0.001, far_clip=100)
| 594 | |
| 595 | |
| 596 | def get_frustum(bbox_image, C, near_clip=0.001, far_clip=100): |
| 597 | """Get frustum corners in camera coordinates. |
| 598 | |
| 599 | Args: |
| 600 | bbox_image (list[int]): box in image coordinates. |
| 601 | C (np.ndarray): Intrinsics. |
| 602 | near_clip (float, optional): Nearest distance of frustum. |
| 603 | Defaults to 0.001. |
| 604 | far_clip (float, optional): Farthest distance of frustum. |
| 605 | Defaults to 100. |
| 606 | |
| 607 | Returns: |
| 608 | np.ndarray, shape=[8, 3]: coordinates of frustum corners. |
| 609 | """ |
| 610 | fku = C[0, 0] |
| 611 | fkv = -C[1, 1] |
| 612 | u0v0 = C[0:2, 2] |
| 613 | z_points = np.array([near_clip] * 4 + [far_clip] * 4, |
| 614 | dtype=C.dtype)[:, np.newaxis] |
| 615 | b = bbox_image |
| 616 | box_corners = np.array( |
| 617 | [[b[0], b[1]], [b[0], b[3]], [b[2], b[3]], [b[2], b[1]]], |
| 618 | dtype=C.dtype) |
| 619 | near_box_corners = (box_corners - u0v0) / np.array( |
| 620 | [fku / near_clip, -fkv / near_clip], dtype=C.dtype) |
| 621 | far_box_corners = (box_corners - u0v0) / np.array( |
| 622 | [fku / far_clip, -fkv / far_clip], dtype=C.dtype) |
| 623 | ret_xy = np.concatenate([near_box_corners, far_box_corners], |
| 624 | axis=0) # [8, 2] |
| 625 | ret_xyz = np.concatenate([ret_xy, z_points], axis=1) |
| 626 | return ret_xyz |
| 627 | |
| 628 | |
| 629 | def surface_equ_3d(polygon_surfaces): |
no outgoing calls
no test coverage detected