PointCloud object#

The PointCloud class is essential for all point cloud operations and processing within this Toolbox. It wraps an Open3D point cloud, which can hold the point coordinates and, optionally, their colors and surface normals.

Open3D is an open-source library that supports rapid development of software that deals with 3D data. The Open3D frontend exposes a set of carefully selected data structures and algorithms in both C++ and Python. The backend is highly optimized and is set up for parallelization.

The PointCloud class provides a subset of commonly used methods but does not attempt to wrap every Open3D method. Instead, any method or property not known to the PointCloud class, such as pc.some_method(), falls through to the native Open3D method some_method() on the encapsulated Open3D object, and all parameters are passed through. If the return value is an Open3D point cloud, or a tuple that contains one, it is wrapped and returned as a PointCloud instance. A name that neither class knows raises AttributeError.

Note

Open3D uses NumPy arrays in which points are rows. This is different to the Toolbox convention of points as columns. The Toolbox wrappers handle this transposition, but anything that falls through to Open3D, or that is reached through pcd, uses the Open3D convention.

class PointCloud(arg: Any, depth_scale: float = 1.0, **kwargs)[source][source]#

A set of 3D points, optionally with colors and surface normals

A thin wrapper around an Open3D open3d.geometry.PointCloud that keeps the Toolbox conventions: points, colors and normals are 3xN arrays with one point per column. Methods that Open3D provides and that are not wrapped here are forwarded to it. See the constructor for the ways to create a point cloud.

Create new point cloud object

Parameters:
  • arg (o3d.geometry.PointCloud, PointCloud, ndarray(3,N)) – point cloud data as an Open3D or MVTB PointCloud object, 3xN array of points.

  • depth_scale (float, optional) – depth scale factor, defaults to 1.0

Raises:
  • RuntimeError – PointCloud class requires Open3D to be installed: pip install open3d or pip install machinevision-toolbox-python[open3d]

  • ValueError – bad arguments

This object wraps an Open3D open3d.geometry.PointCloud object. It can be created from:

  • an Open3D point cloud object

  • a 3xN array of point coordinates

  • a depth image as a 1-plane Image instance

  • an RGBD image as a 4-plane Image instance

  • a tuple of two images (RGB, D) as 3-plane and 1-plane Image instances

Warning

Open3D must be installed.

The wrapped Open3D open3d.geometry.PointCloud object has many methods and properties but rather than writing individual wrappers the __getattr__ picks up these references and invokes them on the underlying Open3D object. Any returned Open3D point cloud objects are converted to a PointCloud instance.

__init__(arg: Any, depth_scale: float = 1.0, **kwargs) → None[source][source]#

Create new point cloud object

Parameters:
  • arg (o3d.geometry.PointCloud, PointCloud, ndarray(3,N)) – point cloud data as an Open3D or MVTB PointCloud object, 3xN array of points.

  • depth_scale (float, optional) – depth scale factor, defaults to 1.0

Raises:
  • RuntimeError – PointCloud class requires Open3D to be installed: pip install open3d or pip install machinevision-toolbox-python[open3d]

  • ValueError – bad arguments

This object wraps an Open3D open3d.geometry.PointCloud object. It can be created from:

  • an Open3D point cloud object

  • a 3xN array of point coordinates

  • a depth image as a 1-plane Image instance

  • an RGBD image as a 4-plane Image instance

  • a tuple of two images (RGB, D) as 3-plane and 1-plane Image instances

Warning

Open3D must be installed.

The wrapped Open3D open3d.geometry.PointCloud object has many methods and properties but rather than writing individual wrappers the __getattr__ picks up these references and invokes them on the underlying Open3D object. Any returned Open3D point cloud objects are converted to a PointCloud instance.

Informational#

__str__

Concise string representation of point cloud parameters

__repr__

Short string representation of the point cloud

__len__

Number of points

Access to point cloud data#

pcd

The wrapped Open3D point cloud

points

Get points as array

colors

Get point color data as array

iscolor

Test if the points have colors

Point cloud i/o#

Read

Create point cloud from file

DepthImage

Create point cloud from depth image

write

Write point cloud to file

disp

Display point cloud using Open3D

Point cloud operations#

copy

Copy point cloud

transform

Transform point cloud

downsample_voxel

Downsample point cloud by voxelization

downsample_random

Downsample point cloud by random selection

voxel_grid

Voxelize point cloud

estimate_normals

Estimate point normals

normals

Get point normal data as array

remove_outlier

Remove point cloud outliers

segment_plane

Find the dominant plane using RANSAC

select

Select points by index

paint

Colorize point cloud

unpaint

Remove the colors from a point cloud

concatenate

Join point clouds

ICP

Register point cloud using ICP

__getattr__

Access Open3D PointCloud methods and attributes

Overloaded operators#

__rmul__

Overloaded * operator to transform points

__imul__

Overloaded *= operator to transform points

__add__

Overloaded the + operator to concatenate point clouds

__radd__

Overloaded the + operator so that sum works on point clouds