pointtorch.operations.numpy

Point cloud processing operations for the use with numpy arrays.

pointtorch.operations.numpy.compute_pairwise_ious(
instances: ndarray,
instance_sizes: ndarray,
eps: float = 1e-08,
) ndarray[source]

Computes pairwise intersection over union (IoU) between instances.

Parameters:
  • instances – List of instances where each instance is represented by a set of point indices that are stored consecutively.

  • instance_sizes – Number of points belonging to each instance.

Returns:

Pairwise IoU scores.

Shape:
  • instances: \((N_1 + ... + N_I)\)

  • instance_sizes: \((I)\)

  • Output: \((I, I)\)

    where

    \(I = \text{ number of instances}\)
    \(N_i = \text{ number of points belonging to the i-th instance}\)
pointtorch.operations.numpy.fit_oriented_bounding_box(
coords: ndarray,
dim: int,
) Tuple[BoundingBox, ndarray, ndarray][source]

Computes the oriented bounding box of a point cloud. The principal components of the point distribution are computed and used as a coordinate basis. The point coordinates are transformed into the coordinate system spanned by this basis and the axis-aligned bounding box is calculated in this coordinate system.

Parameters:
  • coords – Point coordinates.

  • dim – Dimensionality of the bounding box. For example, a 2D bounding box is computed when setting dim to 2. dim must be greater than 1 and smaller or equal to D.

Returns:

A tuple of three elements. The first element is the bounding box, which is represented as an axis-alignedbounding box in the transformed coordinate system. The second element is the transformation matrix, which canbe used to transform point coordinates from the original coordinate system to the coordinate system spanned bythe principal components. The third element is the point coordinates in the transformed coordinate system.

Shape:
  • coords: \((N, D)\)
  • Output transformation matrix: \((D, D)\)
  • Output transformed point coordinates: \((N, D)\)

    where

    \(N = \text{ number of points}\)
    \(D = \text{ number of coordinate dimensions}\)
pointtorch.operations.numpy.make_labels_consecutive(
labels: ndarray[Any, dtype[int64]],
start_id: int = 0,
ignore_id: int | None = None,
inplace: bool = False,
return_unique_labels: bool = False,
) ndarray[Any, dtype[int64]] | Tuple[ndarray[Any, dtype[int64]], ndarray[Any, dtype[int64]]][source]

Transforms the input labels into consecutive integer labels starting from a given start_id.

Parameters:
  • labels – An array of original labels.

  • start_id – The starting ID for the consecutive labels. Defaults to zero.

  • ignore_id – A label ID that should not be changed when transforming the labels.

  • inplace – Whether the transformation should be applied inplace to the labels array. Defaults to False.

  • return_unique_labels – Whether the unique labels after applying the transformation (excluding ignore_id) should be returned. Defaults to False.

Returns:

An array with the transformed consecutive labels. If return_unique_labels is set to True, a tuple of two arrays is returned, where the second array contains the unique labels after the transformation.

pointtorch.operations.numpy.non_max_suppression(
ious: ndarray,
scores: ndarray,
iou_threshold: float,
) ndarray[source]

Non-maximum suppression operation for instance detection.

Parameters:
  • ious – Pairwise intersection over union of all instance proposals.

  • scores – Confidence scores for each instance proposal.

  • iou_threshold – Maximum IoU that two instances can have in order to be kept as separate instances.

Returns:

Indices of the instances remaining after non-maximum suppression.

Shape:
  • ious: \((I, I)\)

  • scores: \((I)\)

  • Output: \((I')\)

    where

    \(I = \text{ number of instance proposals}\)
    \(I' = \text{ number of instances remaining after non-maximum suppression}'\)
pointtorch.operations.numpy.voxel_downsampling(
points: ndarray[Any, dtype[float64]],
voxel_size: float,
point_aggregation: Literal['nearest_neighbor', 'random'] = 'random',
preserve_order: bool = True,
start: ndarray[Any, dtype[float64]] | None = None,
) Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[int64]], ndarray[Any, dtype[int64]]][source]

Voxel-based downsampling of a point cloud.

Parameters:
  • points – The point cloud to downsample.

  • voxel_size – The size of the voxels used for downsampling. If voxel_size is set to zero or less, no downsampling is applied.

  • point_aggregation – Method to be used to aggregate the points within the same voxel. Defaults to nearest_neighbor. "nearest_neighbor": The point closest to the voxel center is selected. "random": One point is randomly sampled from the voxel.

  • preserve_order – If set to True, the point order is preserved during downsampling. This means that for any two points included in the downsampled point cloud, the point that is first in the original point cloud is also first in the downsampled point cloud. Defaults to True.

  • start – Coordinates of a point at which the voxel grid is to be aligned, i.e., the grid is placed so that start is at a corner point of a voxel. Defaults to None, which means that the grid is aligned at the coordinate origin.

Returns:

Tuple of three arrays. The first contains the points remaining after downsampling. The second contains the indices of the points remaining after downsampling within the original point cloud. The third contains the indices of the voxel to which each point in the input point cloud belongs.

Raises:

ValueError – If start is not None and has an invalid shape.

Shape:
  • points: \((N, 3 + D)\).

  • start: \((3)\)

  • Output: Tuple of three arrays. The first has shape \((N', 3 + D)\), the second \((N')\), and the third \((N)\)

    where

    \(N = \text{ number of points before downsampling}\)
    \(N' = \text{ number of points after downsampling}\)
    \(D = \text{ number of feature channels excluding coordinate channels }\)