vis4d.op.geometry.projection¶
Projection utilities.
Functions
|
Generate depth map for given pointcloud. |
|
Generate binary mask. |
|
Project points to pixel coordinates with given intrinsics. |
|
Un-projects pixel coordinates to 3D coordinates with given intrinsics. |
- generate_depth_map(points, intrinsics, image_hw)[source]¶
Generate depth map for given pointcloud.
- Parameters:
points (
Tensor
) – (N, 3) coordinates.intrinsics (
Tensor
) – (3, 3) intrinsic camera matrices.image_hw (
tuple
[int
,int
]) – (tuple[int,int]) height, width of the image
- Returns:
- Projected depth map of the given pointcloud.
Invalid depth has 0 values
- Return type:
torch.Tensor
- points_inside_image(points_coord, depths, images_hw)[source]¶
Generate binary mask.
Creates a mask that is true for all point coordiantes that lie inside the image,
- Parameters:
points_coord (torch.Tensor) – 2D pixel coordinates of shape […, 2].
depths (torch.Tensor) – Associated depth of each 2D pixel coordinate.
images_hw (
Tensor
|tuple
[int
,int
]) – (torch.Tensor| tuple[int, int]]) Associated tensor of image dimensions, shape […, 2] or single height, width pair.
- Returns:
Binary mask of points inside an image.
- Return type:
torch.Tensor
- project_points(points, intrinsics)[source]¶
Project points to pixel coordinates with given intrinsics.
- Parameters:
points (
Tensor
) – (N, 3) or (B, N, 3) 3D coordinates.intrinsics (
Tensor
) – (3, 3) or (B, 3, 3) intrinsic camera matrices.
- Returns:
(N, 2) or (B, N, 2) 2D pixel coordinates.
- Return type:
torch.Tensor
- Raises:
ValueError – Shape of input points is not valid for computation.
- unproject_points(points, depths, intrinsics)[source]¶
Un-projects pixel coordinates to 3D coordinates with given intrinsics.
- Parameters:
points (
Tensor
) – (N, 2) or (B, N, 2) 2D pixel coordinates.depths (
Tensor
) – (N,) / (N, 1) or (B, N,) / (B, N, 1) depth values.intrinsics (
Tensor
) – (3, 3) or (B, 3, 3) intrinsic camera matrices.
- Returns:
(N, 3) or (B, N, 3) 3D coordinates.
- Return type:
torch.Tensor
- Raises:
ValueError – Shape of input points is not valid for computation.