py123d_detection.torch.models.bevformer.utils¶
Geometry for BEVFormer’s bird’s-eye grid.
Three pure functions: lay out the grid, lift each cell into a vertical pillar of 3D points, and project those points into every camera. No parameters, no modules, which is why they are tested directly and reused by the camera renderer rather than reimplemented there.
Functions
|
Lift each BEV cell into a vertical pillar of 3D points, for spatial cross-attention. |
|
Cell centres of the BEV grid, normalised to |
|
Project world-frame points into every camera. |
- py123d_detection.torch.models.bevformer.utils.create_bev_grid(bev_h, bev_w)[source]¶
Cell centres of the BEV grid, normalised to
[0, 1].
- py123d_detection.torch.models.bevformer.utils.create_3d_reference_points(bev_grid, num_heights, pc_range)[source]¶
Lift each BEV cell into a vertical pillar of 3D points, for spatial cross-attention.
A cell has no height, but the cameras that see it do. Sampling a few evenly spaced heights inside the detection range is how a cell finds the pixels that look at it.
- Parameters:
bev_grid (
Tensor) –(Q, 2), fromcreate_bev_grid().num_heights (
int) – Points per pillar.pc_range (
List[float]) –[x_min, y_min, z_min, x_max, y_max, z_max].
- Return type:
Tensor- Returns:
(Q, num_heights, 3)in world coordinates.
- py123d_detection.torch.models.bevformer.utils.project_3d_to_cameras(points_3d, imu2img, pad_h, pad_w)[source]¶
Project world-frame points into every camera.
The projections come from the dataset as
imu2img, which is alreadyintrinsics @ extrinsics, so nothing here has to know how a rig is calibrated.- Parameters:
- Return type:
Tuple[Tensor,Tensor]- Returns:
(coords_2d, valid_mask). Coordinates are(B, N, Q, P, 2)normalised to[0, 1]; the mask is(B, N, Q, P)andTruewhere the point is in front of the camera and inside the image.