lidar_aug.python package¶
This package contains utility code, Python wrappers for point cloud transformations as well as a class to visualize point clouds.
Submodules¶
lidar_aug.python.augmentations module¶
This submodule contains Python wrappers for many transformations. These wrappers do a shape check and, in some instances, do some pre- / post-processing of inputs/outputs.
- lidar_aug.python.augmentations.apply_transformation(points: Tensor, transformation_matrix: Tensor) None¶
Applies a transformation matrix to an entire point cloud with the shape (B, N, F), where B is the number of batches and N is the number of points.
- Parameters:
points – is the point cloud that the transformation matrix is applied to. Expected shape is (B, N, 4).
transformation_matrix – is the transformation matrix.
- lidar_aug.python.augmentations.delete_labels_by_min_points(points: Tensor, labels: Tensor, names: Tensor, min_points: int) None¶
Checks the amount of points for each bounding box. If the number of points is smaller than a given threshold, the box is removed along with its label.
- Parameters:
points – is the point_cloud. Expected shape is (B, N, 4).
labels – are the bounding boxes of objects. Expected shape is (B, N, 7).
names – are the names/labels of these boxes.
min_points – is the point threshold.
- lidar_aug.python.augmentations.flip_random(points: Tensor, labels: Tensor, prob: int) None¶
Flips all the points in the point cloud with a probability of prob % in the direction of the y-axis.
- Parameters:
points – is the point cloud containing the points that will be flipped. Expected shape is (B, N, 4).
labels – are the corresponding labels. Expected shape is (B, N, 7).
prob – is the probability with which the points should be flipped.
- lidar_aug.python.augmentations.intensity_noise(points: Tensor, sigma: float, max_intensity: IntensityRange) None¶
Shifts the intensity value of every point in the point cloud by a random amount drawn from a normal distribution.
- Parameters:
points – is the point cloud with all the points. Expected shape is (B, N, 4).
sigma – is the standard deviation of the normal distribution.
max_intensity – is the maximum intensity value (either 1 or 255, depending on the dataset).
- lidar_aug.python.augmentations.intensity_shift(points: Tensor, sigma: float, max_intensity: IntensityRange) None¶
Shifts the intensity value of every point in the point cloud by a single value drawn from a normal distribution.
- Parameters:
points – is the point cloud with all the points. Expected shape is (B, N, 4).
sigma – is the standard deviation of the normal distribution.
max_intensity – is the maximum intensity value (either 1 or 255, depending on the dataset).
- lidar_aug.python.augmentations.local_to_local_transform(from_pose: Tensor, to_pose: Tensor) Tensor¶
Creates a transformation matrix from the local system into a ‘target’ coordinate frame.
- Parameters:
from_pose – is the local coordinate frame (x, y, z, roll, yaw, pitch).
to_pose – is the target coordinate frame (x, y, z, roll, yaw, pitch).
- Returns:
the homogeneous transformation matrix into the target coordinate frame.
- lidar_aug.python.augmentations.local_to_world_transform(lidar_pose: Tensor) Tensor¶
Creates a transformation matrix from the local system into the global coordinate frame.
- Parameters:
lidar_pose – is the local coordinate frame (x, y, z, roll, yaw, pitch).
- Returns:
the homogeneous transformation matrix into the global coordinate frame.
- lidar_aug.python.augmentations.random_noise(points: Tensor, sigma: float, ranges: list[float] | DistributionRanges, noise_type: NoiseType, max_intensity: IntensityRange) None¶
Adds random amount of points (drawn using a normal distribution) at random coordinates (within predetermined ranges) with a random intensity according to specific noise type.
- Parameters:
points – is the point cloud that the points will be added to. Expected shape is (B, N, 4).
sigma – is the standard deviation of the normal distribution that is used to draw the number of points to be added.
ranges – are the boundaries in (min and max (x, y, z) values) in which the new points can be created.
noise_type – is one of a number of ‘patterns’ that can be used to generate the points.
max_intensity – is the maximum intensity value in the dataset
- lidar_aug.python.augmentations.random_point_noise(points: Tensor, sigma: float) None¶
Moves each point in the point cloud randomly. How much each coordinate is changed is decided by values drawn from a normal distribution.
- Parameters:
points – is the point cloud from which each point is moved. Expected shape is (B, N, 4).
sigma – is the standard deviation of the normal distribution.
- lidar_aug.python.augmentations.rotate_deg(points: Tensor, angle: float) None¶
Rotates a batch of points along the ‘z’ axis (yaw).
- Parameters:
points – is the point cloud that the rotation is applied to. Expected shape is (B, N, 4).
angle – is the angle (in degrees) by which the points are to be rotated.
- lidar_aug.python.augmentations.rotate_rad(points: Tensor, angle: float) None¶
Rotates a batch of points along the ‘z’ axis (yaw).
- Parameters:
points – is the point cloud that the rotation is applied to. Expected shape is (B, N, 4).
angle – is the angle (in radians) by which the points are to be rotated.
- lidar_aug.python.augmentations.rotate_random(points: Tensor, labels: Tensor, sigma: float) None¶
Rotates points and labels. The number of degrees that they are rotated by is determined by a randomly generated value from a normal distribution.
- Parameters:
points – is the point cloud that the rotation is applied to. Expected shape is (B, N, 4).
labels – are the labels belonging to the point cloud that the rotation is applied to. Expected shape is (B, N, 7).
sigma – is the standard deviation of the normal distribution.
- lidar_aug.python.augmentations.scale(points: Tensor, scaling_factor: float) None¶
Scales points by a constant factor.
- Parameters:
points – is the point cloud whose points are scaled. Expected shape is (B, N, 4).
scaling_factor – is the factor that the (x, y, z) coordinates are multiplied by.
- lidar_aug.python.augmentations.scale_local(points: Tensor, labels: Tensor, sigma: float, max_scale: float) None¶
Scales the points that are part of a box and the corresponding labels by a random factor.
This factor is drawn from a truncated normal distribution. The truncated normal distribution has a mean of 1. The standard deviation, as well as upper and lower limits are determined by the function parameters.
- Parameters:
points – is the point cloud that contains the points that will be scaled. Expected shape is (B, N, 4).
labels – are the labels belonging to the aforementioned point cloud. Expected shape is (B, N, 7).
sigma – is the standard deviation of the truncated normal distribution.
max_scale – is the upper limit of the truncated normal distribution. The lower limit is the inverse.
- lidar_aug.python.augmentations.scale_random(points: Tensor, labels: Tensor, sigma: float, max_scale: float) None¶
Scales the points and labels by a random factor. This factor is drawn from a truncated normal distribution. The truncated normal distribution has a mean of 1. The standard deviation, as well as upper and lower limits are determined by the function parameters.
- Parameters:
points – is the point cloud that contains the points that will be scaled. Expected shape is (B, N, 4).
labels – are the labels belonging to the aforementioned point cloud. Expected shape is (B, N, 7).
sigma – is the standard deviation of the truncated normal distribution.
max_scale – is the upper limit of the truncated normal distribution. The lower limit is the inverse.
- lidar_aug.python.augmentations.thin_out(points: Tensor, sigma: float) None¶
Randomly generates a percentage from a normal distribution, which determines how many items should be ‘thinned out’. From that percentage random indices are uniformly drawn (in a random order, where each index is unique).
Finally, a new tensor is created containing the items present at those indices.
- Parameters:
points – is the point cloud. Expected shape is (B, N, 4).
sigma – is the standard deviation of the distribution that generates the percentage.
- lidar_aug.python.augmentations.transform_along_ray(points: Tensor, sigma: float) None¶
Moves each point in the point cloud randomly along a ray. How much it is moved is decided by a value drawn from a normal distribution.
- Parameters:
points – is the point cloud from which each point is moved. Expected shape is (B, N, 4).
sigma – is the standard deviation of the normal distribution.
- lidar_aug.python.augmentations.translate(points: Tensor, translation: Tensor) None¶
Moves points by a specific amount.
- Parameters:
points – is the point cloud with the points are to be moved. Expected shape is (B, N, 4).
translation – is the translation vector that specifies by how much they points are moved.
- lidar_aug.python.augmentations.translate_random(points: Tensor, labels: Tensor, sigma: float) None¶
Generates a random (3D) translation vector using a normal distribution and applies it to all the points and labels.
- Parameters:
points – is the point cloud with the points that are translated. Expected shape is (B, N, 4).
labels – are the labels belonging to the aforementioned point cloud. Expected shape is (B, N, 7).
sigma – is the standard deviation of the normal distribution.
lidar_aug.python.utils module¶
This submodule contains various utility functions.
- class lidar_aug.python.utils.Calibration(calib_file)¶
Bases:
object- cart_to_hom(pts)¶
- Parameters:
pts – (N, 3 or 2)
- Return pts_hom:
(N, 4 or 3)
- corners3d_to_img_boxes(corners3d)¶
- Parameters:
corners3d – (N, 8, 3) corners in rect coordinate
- Returns:
boxes: (None, 4) [x1, y1, x2, y2] in rgb coordinate
- Returns:
boxes_corner: (None, 8) [xi, yi] in rgb coordinate
- img_to_rect(u, v, depth_rect)¶
- Parameters:
u –
v –
depth_rect –
- Returns:
- lidar_to_img(pts_lidar)¶
- Parameters:
pts_lidar – (N, 3)
- Return pts_img:
(N, 2)
- lidar_to_rect(pts_lidar)¶
- Parameters:
pts_lidar – (N, 3)
- Return pts_rect:
(N, 3)
- rect_to_img(pts_rect)¶
- Parameters:
pts_rect – (N, 3)
- Return pts_img:
(N, 2)
- rect_to_lidar(pts_rect)¶
- Parameters:
pts_lidar – (N, 3)
- Return pts_rect:
(N, 3)
- class lidar_aug.python.utils.Object3d(line)¶
Bases:
object- cam_to_velo(calib)¶
- generate_corners3d()¶
- get_lidar_bbox(calib)¶
- lidar_aug.python.utils.boxes_to_corners_3d(boxes3d)¶
Creates a box representation using its corners like this:
7 -------- 4 /| /| 6 -------- 5 . | | | | . 3 -------- 0 |/ |/ 2 -------- 1
- Parameters:
boxes3d – (N, 7) [x, y, z, dx, dy, dz, heading], (x, y, z) is the box center
- Returns:
a new tensor representing the box by its eight corners
- lidar_aug.python.utils.check_numpy_to_torch(x)¶
- lidar_aug.python.utils.create_distribution_ranges(input: list) DistributionRanges¶
- lidar_aug.python.utils.get_calib_from_file(calib_file)¶
- lidar_aug.python.utils.get_objects_from_label(label_file)¶
- lidar_aug.python.utils.gt_boxes_from_label(label_file, calib)¶
- lidar_aug.python.utils.in_hull(p, hull)¶
- Parameters:
p – (N, K) test points
hull – (M, K) M corners of a box
- Returns:
bool
- lidar_aug.python.utils.load_point_cloud_from_file(pc_path, point_features=4, normalize_intensities=False)¶
- lidar_aug.python.utils.points_in_boxes_cpu(points, boxes)¶
- Parameters:
points – (num_points, 3)
boxes – [x, y, z, dx, dy, dz, heading], (x, y, z) is the box center, each box DO NOT overlaps
- Returns:
(N, num_points)
- Return type:
point_indices
lidar_aug.python.visualization module¶
This submodule contains functions to visualize point clouds.
- class lidar_aug.python.visualization.PCViewer(point_cloud=None, gt_boxes=None, pred_boxes=None, point_features=4, normalize_intensities=False, calib=None)¶
Bases:
object- draw(normalize_intensities=False)¶
- set_gt_boxes(gt_boxes)¶
- set_gt_boxes_from_label(label_file, calib_file)¶
- set_point_cloud(point_cloud)¶
- set_pred_boxes(pred_boxes, pred_scores=None, min_score=0.5)¶