kaolin.rep.PointCloud

class PointCloud(points: Optional[torch.Tensor] = None, normals: torch.Tensor = None, device: Optional[str] = 'cpu', copy: Optional[bool] = False)[source]

Base class to hold pointcloud objects.

__init__(points: Optional[torch.Tensor] = None, normals: torch.Tensor = None, device: Optional[str] = 'cpu', copy: Optional[bool] = False)[source]

Initialize a PointCloud object, given a tensor of points, and optionally, a tensor representing poincloud normals.

Parameters
  • pts (torch.Tensor) – Points that make up the pointcloud (shape: \(... \times N \times D\)), where \(N\) denotes the number of points in the cloud, and \(D\) denotes the dimensionality of each point.

  • normals (torch.Tensor) – Normals for each point in the cloud (shape: \(N \times D\), where D = 2 or D = 3). That is, normals can only be provided for 2D or 3D pointclouds.

  • device (str, Optional) – Device to store the pointcloud object on (default: ‘cpu’). Must be a valid torch.device type.

  • copy (bool, Optional) – Whether or not to create a deep copy of the Tensor(s) used to initialze class members.

bounding_points(points: torch.Tensor, bbox: list, padding: float = 0.05)[source]

Returns the indices of a set of points which lies within a supplied bounding box.

Parameters
  • point (torch.Tensor) – Input pointcloud

  • bbox (list) – bouding box values (min_x, max_x, min_y, max_y, min_z, max_z)

  • padding (float) – padding to add to bounding box

Returns

list of indices which lie within supplied bounding box

Return type

(list)

Example

>>> points = torch.rand(1000)
>>> subset_idx = bounding_points(points, [.1, .9, .1, .9, .1, .9])
>>> subset = points[subset_idx]
random_input_dropout(points: torch.Tensor, max_dropout_rate: float = 0.95)[source]

Returns a copy of the given cloud with points randomly removed according to max_dropout_rate.

For each batch, first select a dropout_rate from the uniform distribution [0, max_dropout_rate], then remove (i.e. set to an existing point) with a probability equal to the dropout rate.

Based on the technique described in PointNet++.

Parameters
  • points (torch.Tensor or np.ndarray) – Input pointcloud shape = (batch_size, num_points, num_dim) or (num_points, num_dim)

  • max_dropout_rate (float) – See method description above.