A brief tutorial on Open3D point cloud processing

Insert image description here

Recommended: Use NSDT editor to quickly build programmable 3D scenes

This is a continuation of the "Getting Started with LiDAR" article. In this article, we will look at Python libraries and Open3D data structures for working with point clouds, perform visualizations, and manipulate point cloud data for subsequent analysis and processing.

If you need to quickly preview 3D point clouds or convert PCD point clouds to other formats, the easier way is to use NSDT 3DConvert , a powerful online tool that supports online preview and conversion of dozens of 3D format files without the need for Install any software locally:
Insert image description here

https://3dconvert.nsdt.cloud

1. What is point cloud data?

Referring to the first article I wrote, lidar data is usually represented as a point cloud, which contains n points and mainly has the following properties:

  • X coordinate
  • Y coordinate
  • Z coordinate

The points may also have an "intensity" value corresponding to each point, which simply represents the light energy returned to the sensor after being emitted from a 3D scanner such as a lidar sensor.

However, it is worth noting that point clouds can also be generated from other 3D scanners and computer-aided design (CAD) models.

2. Tools for visualizing point cloud data

There are many tools for visualizing 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 visualizing and exploring 3D data structures, and more importantly point cloud data.

3. Open3D data structure

Open3d is an open source software package that supports the development and processing of 3D data (such as lidar) using Python and C++. For more information about Open3D, you can access the documentation here .

Open3D handles different data structures and point cloud data, such as:

  • voxel grid

A voxel is usually described as a three-dimensional pixel of a 2D image and is the abbreviation of volume pixel. The voxel mesh is constructed/derived from the point cloud as follows:
Insert image description here

Voxel grid example

  • octree

An octree is a tree-shaped data structure in which each internal node has eight child nodes. Octrees can be used to divide a three-dimensional space by subdividing it into eight octants.

Insert image description here

Octree data structure

  • grid

In 3D computer graphics, a mesh consists of vertices, edges, and faces that define the shape of an object. There are polygon meshes and triangle meshes.

  • point cloud data

Point clouds consist of millions of geo-referenced points.

Below is a comparison image between mesh and point cloud data:
Insert image description here

Difference Between Mesh and Point Cloud

  • RGB data class and depth image class

4. Install Open3D

To clearly understand what a point cloud is, let’s go ahead and install the necessary tools that will help in processing the data:

!pip install open3d

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

Since we will be dealing with 3-dimensional data, it is always a good idea to install numpy, matplotlib and open3d.

5. Handle different data formats

When looking at the Open3D dataset, you will notice different types of file formats that store 3D data, some of which are as follows:

  • Polygon File Format (PLY): Simply put, PLY is a file format used to store 3D data as a collection of polygons.

Let's use the following code as an example of PLY format:

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 via ply_point_cloud = o3d.data.PLYPointCloud().

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

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

To visualize the point cloud, we will use the draw_plotly function. It accepts multiple parameters:

  • Zoom: lens distance
  • Camera Position: camera position
  • Up Vector: upward vector
  • PCD variable containing cloud points

The result is as follows:
Insert image description here

PCD data result graph in PLY format

  • Point cloud data (PCD)

PCD is a file format used for storing and exchanging 3D point cloud data (the topic we are interested in in this article). This file format typically stores information about (X,Y,Z) coordinates, intensity, and color.

Again, let's take a look at the available datasets in point clouds:

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])

Insert image description here

PCD dataset from Open3D

6. Conclusion

This was a brief introduction to point clouds and the visualization of point clouds in different formats, in the next tutorial we will take a closer look at other useful features of Open3D for working with point clouds, such as plane segmentation and applying DBSCAN.


Original link: Introduction to Open3D point cloud processing—BimAnt

Guess you like

Origin blog.csdn.net/shebao3333/article/details/133345442