Gentle Introduction to Point Clouds in Open3D

Amnah Ebrahim
4 min readMar 11, 2023

This a continuation to “Getting Started with Lidar” article. You can go ahead and watch a video tutorial or continue reading! In this article we will be:

  • Taking a looking at python libraries for processing point clouds
  • Looking at Open3D Data Structures
  • Visualising and Manipulating Point Cloud Data

Let’s refresh…What’s Point Cloud Data?

Referencing the first article I wrote, Lidar data is usually represented as point clouds that contain n number of points with the following attributes primarily:

  • X coordinate
  • Y coordinate
  • Z coordinate

These points may also have an “intensity” value that corresponds to each point, which simply represents the amount of light energy returned to the sensor after being emitted from 3D Scanners like Lidar Sensors.

However, it’s important to note that point clouds can be generated from other 3D scanners and Computer Aided Design (CAD) models.

Tools for Visualising Point Cloud Data:

There are many tools for visualising lidar point clouds, such as the following software and libraries:

  • Point Cloud Library
  • CloudCompare
  • MeshLab
  • MATLAB
  • Autodesk Recap
  • Open3D

This tutorial focuses on Open3D for visualising and exploring 3d data structures, more importantly Point Cloud Data.

Open3D Data Structures:

Open3d is an open-source library that supports both python and C++ development of software that deals with 3D data such as lidar.

For more information on Open3D be sure to visit the documentation here.

Open3D deals with different data structures alongside point cloud data, such as:

  • Voxel Grids:

Often voxels are described as three-dimensional pixels of a 2D image and are short for volume pixels. Voxel Grids are made from/derived from point clouds, and are as shown below:

Voxel Grid Example [Source: click here]
  • Octree: An octree is a tree data structure in which each internal node has eight subnodes. Octrees are useful to partition three -dimensional space by subdividing it into eight octants.
GIF showcasing octree data structure
  • Meshes:

In 3D computer graphics, a mesh is made up of vertices, edges and faces that defines the shape of an object. There are polygon meshes and triangular meshes.

  • Point Cloud Data:

Point clouds are made of millions of georeferenced points.

Below is an image that compares between meshes and point cloud data:

Difference between meshes and point clouds
  • RGB Data class and Depth Image class

Getting our hands dirty…

For us to get a clear idea on what point clouds are, let’s go ahead and install the necessary tools that will aid in processing data:

!pip install open3d

import numpy as np
import matplotlib.pyplot as plt
import open3d as o3d

As we will be dealing with 3 dimensional data, it’s always a good idea to install numpy, matplotlib, and open3d.

Dealing with different data formats:

When looking into the Open3D Dataset, you’ll notice different types of file formats that store 3D data, some of which are the following:

  • Polygon File Format (PLY): PLY simply put is a file format used for storing 3D data as a collection of polygons.

Let’s let an example of PLY format using the following code:

ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)
print(pcd)
print(np.asarray(pcd.points))
o3d.visualization.draw_plotly([pcd],
zoom=0.3412,
front=[0.4257, -0.2125, -0.8795],
lookat=[2.6172, 2.0475, 1.532],
up=[-0.0694, -0.9768, 0.2024])

First we create an instance of the PLYPointCloud class from Open3D from ply_point_cloud = o3d.data.PLYPointCloud().

Then using the read_point_cloud function provided by Open3D, we will read the path of the instance created and store it into a pcd variable. When we print it, the output is some basic information about the point cloud, such as the number of points and the range of coordinates.

When we convert the open3d format of data into a numpy array using the np.asarray, the array generated will contain (X,Y,Z) coordinates of each point in the cloud.

To visualise the point cloud, we will be using the draw_plotly function. It takes in multiple arguments:

  • Zoom
  • Camera Position
  • Up vector
  • PCD variable containing the points of cloud

The result is as follows:

Resulting plot for PCD data from PLY format
  • Point Cloud Data(PCD): is a file format used to store and exchange 3D point cloud data (our topic of interest in this article). This file format typically stores information on (X,Y,Z) coordinates, intensity, and color.

Similarly let’s look at an available dataset from point cloud:

dataset = o3d.data.PCDPointCloud()
pcd = o3d.io.read_point_cloud(dataset.path)
print(pcd)
print(np.asarray(pcd.points))
o3d.visualization.draw_plotly([pcd],
zoom=0.3412,
front=[0.4257, -0.2125, -0.8795],
lookat=[2.6172, 2.0475, 1.532],
up=[-0.0694, -0.9768, 0.2024])
PCD Dataset from Open3D

Conclusion

As this is a gentle introduction to point clouds, and visualisation of different formats of point clouds, in the next tutorial, we will be taking a closer look at other useful functionalities of Open3D for dealing with point clouds such as plane segmentation and applying DBSCAN.

--

--

Amnah Ebrahim

Electronics engineer passionate about electronics, machine learning, autonomous robotics, and natural language processing!