vision3d.transforms.functional#
Functional form of the 3D transforms in vision3d.transforms.
Functions
|
Update |
|
Update |
|
Flip a tensor along a 3D spatial axis. |
|
Flip 3D bounding boxes along |
|
Flip point cloud coordinates along |
Flip |
|
Update |
|
Update |
|
Flip a |
|
|
Add Gaussian noise to the xyz coordinates of a point cloud. |
|
Add Gaussian noise to point xyz coordinates. |
|
Update |
|
Register a kernel for a functional and TVTensor type. |
|
Resample a grid into a target grid layout. |
|
Resample a label grid into a target layout. |
|
Update |
|
Update |
|
Rotate a tensor by a 3x3 rotation matrix. |
|
Rotate 3D bounding boxes by |
|
Update camera extrinsics after rotating the lidar frame. |
|
Rotate point cloud coordinates by |
|
Randomly sample a point cloud to |
|
Randomly subsample (or oversample with replacement) to |
|
Scale a tensor by a uniform factor. |
|
Scale 3D bounding boxes by |
|
Update camera extrinsics after scaling the lidar frame. |
|
Scale point cloud coordinates by |
|
Randomly shuffle the points of a point cloud. |
|
Randomly permute point order. |
|
Translate a tensor by a 3D offset. |
|
Translate 3D bounding boxes by |
|
Update camera extrinsics after translating the lidar frame. |
|
Translate point cloud coordinates by |
Flip |
|
Update |
|
Update |
|
Flip a |
- vision3d.transforms.functional.center_crop_camera_intrinsics(inpt, output_size)[source]#
Update
CameraIntrinsicsfor a center crop of the corresponding image.- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
output_size (list[int]) – Target
(h, w)after the center crop.
- Returns:
Updated intrinsics with
image_sizeset tooutput_size.- Return type:
- vision3d.transforms.functional.crop_camera_intrinsics(inpt, top, left, height, width)[source]#
Update
CameraIntrinsicsfor a crop of the corresponding image.Shifts the principal point so projection through the updated intrinsics matches projection through the original intrinsics on the cropped image.
- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
top (int) – Top edge of the crop in pixels.
left (int) – Left edge of the crop in pixels.
height (int) – Crop height in pixels.
width (int) – Crop width in pixels.
- Returns:
Updated intrinsics with
image_sizeset to(height, width).- Return type:
- vision3d.transforms.functional.flip_3d(inpt, *, axis)[source]#
Flip a tensor along a 3D spatial axis.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Flipped tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3DorBoundingBoxes3D.- Return type:
- vision3d.transforms.functional.flip_3d_bounding_boxes(boxes, *, format, axis)[source]#
Flip 3D bounding boxes along
axis.- Parameters:
boxes (Tensor) – Bounding box tensor
[..., K].format (BoundingBox3DFormat) – Format of the boxes.
axis (str) – One of
"x","y","z".
- Returns:
Flipped bounding boxes with the same shape.
- Return type:
- vision3d.transforms.functional.flip_3d_point_cloud(points, *, axis)[source]#
Flip point cloud coordinates along
axis.
- vision3d.transforms.functional.horizontal_flip_bounding_boxes_3d(inpt)[source]#
Flip
BoundingBoxes3Dto match a horizontal image flip.Reflects the source frame’s Y axis following the fixed world-axis convention for a horizontal flip. The paired extrinsics kernel applies the matching camera-frame reflection, so projection stays consistent for any camera pose.
- Parameters:
inpt (BoundingBoxes3D) – The boxes to flip.
- Returns:
The flipped boxes with the same format.
- Return type:
- vision3d.transforms.functional.horizontal_flip_camera_extrinsics(inpt)[source]#
Update
CameraExtrinsicsfor a horizontal image flip.Reflects the source frame about its Y axis (paired with a camera-frame X reflection) so the source-to-camera mapping stays consistent with the horizontally flipped image.
- Parameters:
inpt (CameraExtrinsics) – The extrinsics to update.
- Returns:
Updated extrinsics with the same shape.
- Return type:
- vision3d.transforms.functional.horizontal_flip_camera_intrinsics(inpt)[source]#
Update
CameraIntrinsicsfor a horizontal flip of the corresponding image.Mirrors the principal point about the image’s vertical center line and negates the skew so projection through the updated intrinsics matches projection through the original intrinsics on the flipped image.
- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
- Returns:
Updated intrinsics with the same
image_size.- Return type:
- vision3d.transforms.functional.horizontal_flip_point_cloud_3d(inpt)[source]#
Flip a
PointCloud3Dto match a horizontal image flip.Reflects the source frame’s Y axis following the fixed world-axis convention for a horizontal flip. The paired extrinsics kernel applies the matching camera-frame reflection, so projection stays consistent for any camera pose.
- Parameters:
inpt (PointCloud3D) – The point cloud to flip.
- Returns:
The flipped point cloud.
- Return type:
- vision3d.transforms.functional.jitter_points(inpt, *, sigma)[source]#
Add Gaussian noise to the xyz coordinates of a point cloud.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Jittered tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D.- Return type:
- vision3d.transforms.functional.jitter_points_point_cloud(points, *, sigma)[source]#
Add Gaussian noise to point xyz coordinates.
- vision3d.transforms.functional.pad_camera_intrinsics(inpt, padding, **kwargs)[source]#
Update
CameraIntrinsicsfor a pad of the corresponding image.Shifts the principal point by the top-left pad and grows
image_sizeto include the padded borders.- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
padding (int | list[int]) – Padding spec as accepted by
torchvision.transforms.v2.functional.pad().kwargs (Any) – Unused; accepted for signature compatibility with
torchvision.transforms.v2.functional.pad().
- Returns:
Updated intrinsics with the padded
image_size.- Return type:
- vision3d.transforms.functional.register_kernel(functional, tv_tensor_cls, *, tv_tensor_wrapper=True)[source]#
Register a kernel for a functional and TVTensor type.
- Parameters:
functional (Callable[[...], Any]) – The functional to register a kernel for.
tv_tensor_cls (type[TVTensor]) – The TVTensor subclass this kernel handles.
tv_tensor_wrapper (bool) – If True (default), the kernel receives an unwrapped pure tensor and the output is automatically re-wrapped. If False, the kernel receives the full TVTensor and must handle wrap itself.
- Returns:
Decorator that registers the kernel.
- Return type:
- vision3d.transforms.functional.resample_grid(inpt, *, affine, size, interpolation=InterpolationMode.NEAREST, fill=None)[source]#
Resample a grid into a target grid layout.
Dispatcher entry point.
- Parameters:
inpt (Tensor) – Input tensor.
affine (Tensor) –
[4, 4]index-to-frame transform of the target grid.size (Sequence[int]) – Spatial size of the target grid,
(H, W)or(D, H, W).interpolation (str | InterpolationMode | int) – Desired interpolation enum defined by
torchvision.transforms.v2.InterpolationMode. Accepted string values are"nearest"and"bilinear"(requires torchvision 0.28 or later). Default is"nearest". The correspondingInterpolationModeenum values and Pillow integer constants, e.g.PIL.Image.BILINEARare accepted as well.fill (list[float] | None) – Value for target cells that fall outside the input grid, either a single value or one value per channel.
Nonemeans 0.
- Returns:
Resampled tensor.
- Return type:
- vision3d.transforms.functional.resample_grid_mask_3d(mask, *, input_affine, affine, size, interpolation=InterpolationMode.NEAREST, fill=None)[source]#
Resample a label grid into a target layout.
- Parameters:
mask (Tensor) – Grid data
[C, H, W]or[C, D, H, W].input_affine (Tensor) –
[4, 4]index-to-frame transform ofmask.affine (Tensor) –
[4, 4]index-to-frame transform of the target grid.size (Sequence[int]) – Spatial size of the target grid,
(H, W)or(D, H, W).interpolation (str | InterpolationMode | int) – Desired interpolation enum defined by
torchvision.transforms.v2.InterpolationMode. Accepted string values are"nearest"and"bilinear"(requires torchvision 0.28 or later). Default is"nearest". The correspondingInterpolationModeenum values and Pillow integer constants, e.g.PIL.Image.BILINEARare accepted as well. Bilinear requires a floating pointmask.fill (list[float] | None) – Value for target cells that fall outside
mask, either a single value or one value per channel.Nonemeans 0.
- Raises:
ValueError – If
interpolationis bilinear andmaskis not floating point.NotImplementedError – Always, until resampling is implemented.
- Return type:
- vision3d.transforms.functional.resize_camera_intrinsics(inpt, size, max_size=None, **kwargs)[source]#
Update
CameraIntrinsicsfor a resize of the corresponding image.Scales the focal lengths, skew, and principal point so projection through the updated intrinsics matches projection through the original intrinsics on the resized image.
- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
max_size (int | None) – Optional cap on the longer edge.
kwargs (Any) – Unused; accepted for signature compatibility with
torchvision.transforms.v2.functional.resize().
- Returns:
Updated intrinsics with the new
image_size.- Return type:
- vision3d.transforms.functional.resized_crop_camera_intrinsics(inpt, top, left, height, width, size, **kwargs)[source]#
Update
CameraIntrinsicsfor a crop followed by a resize.- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
top (int) – Top edge of the crop in pixels.
left (int) – Left edge of the crop in pixels.
height (int) – Crop height in pixels.
width (int) – Crop width in pixels.
kwargs (Any) – Unused; accepted for signature compatibility with
torchvision.transforms.v2.functional.resized_crop().
- Returns:
Updated intrinsics with
image_sizeset tosize.- Return type:
- vision3d.transforms.functional.rotate_3d(inpt, *, rotation_matrix)[source]#
Rotate a tensor by a 3x3 rotation matrix.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Rotated tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D,BoundingBoxes3D, orCameraExtrinsics.- Return type:
- vision3d.transforms.functional.rotate_3d_bounding_boxes(boxes, *, format, rotation_matrix)[source]#
Rotate 3D bounding boxes by
rotation_matrix.Only rotated formats are supported:
XYZLWHY: only Z-axis rotations (pure yaw).XYZLWHYPR: arbitrary rotations.
Axis-aligned formats (
XYZXYZ,XYZLWH) cannot represent rotation and will raiseNotImplementedError.- Parameters:
boxes (Tensor) – Bounding box tensor
[..., K].format (BoundingBox3DFormat) – Format of the boxes.
rotation_matrix (Tensor) –
[3, 3]rotation matrix.
- Returns:
Rotated bounding boxes with the same shape.
- Raises:
NotImplementedError – If
formatis axis-aligned.ValueError – If
formatisXYZLWHYand rotation is not pure yaw.
- Return type:
- vision3d.transforms.functional.rotate_3d_camera_extrinsics(extrinsics, *, rotation_matrix)[source]#
Update camera extrinsics after rotating the lidar frame.
The lidar-to-camera extrinsic
Esatisfiesp_cam = E @ p_lidar. After rotating the lidar frame byR, points becomep' = R @ p, soE' = E @ R_invto keepp_cam = E' @ p'.
- vision3d.transforms.functional.rotate_3d_point_cloud(points, *, rotation_matrix)[source]#
Rotate point cloud coordinates by
rotation_matrix.
- vision3d.transforms.functional.sample_points(inpt, *, n)[source]#
Randomly sample a point cloud to
npoints.Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Sampled tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D.- Return type:
- vision3d.transforms.functional.sample_points_point_cloud(points, *, n)[source]#
Randomly subsample (or oversample with replacement) to
npoints.
- vision3d.transforms.functional.scale_3d(inpt, *, factor)[source]#
Scale a tensor by a uniform factor.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Scaled tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D,BoundingBoxes3D, orCameraExtrinsics.- Return type:
- vision3d.transforms.functional.scale_3d_bounding_boxes(boxes, *, format, factor)[source]#
Scale 3D bounding boxes by
factor.Scales both position and dimensions. Rotation angles are unchanged.
- Parameters:
boxes (Tensor) – Bounding box tensor
[..., K].format (BoundingBox3DFormat) – Format of the boxes.
factor (float) – Scale factor.
- Returns:
Scaled bounding boxes with the same shape.
- Return type:
- vision3d.transforms.functional.scale_3d_camera_extrinsics(extrinsics, *, factor)[source]#
Update camera extrinsics after scaling the lidar frame.
- vision3d.transforms.functional.scale_3d_point_cloud(points, *, factor)[source]#
Scale point cloud coordinates by
factor.
- vision3d.transforms.functional.shuffle_points(inpt)[source]#
Randomly shuffle the points of a point cloud.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
inpt (Tensor) – Input tensor.
- Returns:
Shuffled tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D.- Return type:
- vision3d.transforms.functional.shuffle_points_point_cloud(points)[source]#
Randomly permute point order.
- vision3d.transforms.functional.translate_3d(inpt, *, offset)[source]#
Translate a tensor by a 3D offset.
Dispatcher entry point. Type-specific kernels are registered below.
- Parameters:
- Returns:
Translated tensor.
- Raises:
TypeError – If
inptis not an instance ofPointCloud3D,BoundingBoxes3D, orCameraExtrinsics.- Return type:
- vision3d.transforms.functional.translate_3d_bounding_boxes(boxes, *, format, offset)[source]#
Translate 3D bounding boxes by
offset.- Parameters:
boxes (Tensor) – Bounding box tensor
[..., K].format (BoundingBox3DFormat) – Format of the boxes.
offset (Tensor) – Translation
[3]as(tx, ty, tz).
- Returns:
Translated bounding boxes with the same shape.
- Return type:
- vision3d.transforms.functional.translate_3d_camera_extrinsics(extrinsics, *, offset)[source]#
Update camera extrinsics after translating the lidar frame.
The lidar-to-camera extrinsic translation changes because the lidar origin moved by
offsetin the lidar frame.
- vision3d.transforms.functional.translate_3d_point_cloud(points, *, offset)[source]#
Translate point cloud coordinates by
offset.
- vision3d.transforms.functional.vertical_flip_bounding_boxes_3d(inpt)[source]#
Flip
BoundingBoxes3Dto match a vertical image flip.Reflects the source frame’s Z axis following the fixed world-axis convention for a vertical flip. The paired extrinsics kernel applies the matching camera-frame reflection, so projection stays consistent for any camera pose.
- Parameters:
inpt (BoundingBoxes3D) – The boxes to flip.
- Returns:
The flipped boxes with the same format.
- Return type:
- vision3d.transforms.functional.vertical_flip_camera_extrinsics(inpt)[source]#
Update
CameraExtrinsicsfor a vertical image flip.Reflects the source frame about its Z axis (paired with a camera-frame Y reflection) so the source-to-camera mapping stays consistent with the vertically flipped image.
- Parameters:
inpt (CameraExtrinsics) – The extrinsics to update.
- Returns:
Updated extrinsics with the same shape.
- Return type:
- vision3d.transforms.functional.vertical_flip_camera_intrinsics(inpt)[source]#
Update
CameraIntrinsicsfor a vertical flip of the corresponding image.Mirrors the principal point about the image’s horizontal center line and negates the skew so projection through the updated intrinsics matches projection through the original intrinsics on the flipped image.
- Parameters:
inpt (CameraIntrinsics) – The intrinsics to update.
- Returns:
Updated intrinsics with the same
image_size.- Return type:
- vision3d.transforms.functional.vertical_flip_point_cloud_3d(inpt)[source]#
Flip a
PointCloud3Dto match a vertical image flip.Reflects the source frame’s Z axis following the fixed world-axis convention for a vertical flip. The paired extrinsics kernel applies the matching camera-frame reflection, so projection stays consistent for any camera pose.
- Parameters:
inpt (PointCloud3D) – The point cloud to flip.
- Returns:
The flipped point cloud.
- Return type: