Mastering 3D Computer Vision & Point Cloud Processing- Mod 8–How to Visualize Point Cloud Data with Tools-Libraries-Software

Rajavel PM (RPM)
5 min readApr 18, 2024

--

Introduction:

Welcome to the ✍️“3D Computer Vision & Point Cloud Processing Blog Series”. This series of blogs is your 🚀 hands-on guide to mastering 3D point cloud processing with Python.

In this post, we’ll delve into how to visualize point cloud data using tools, libraries and software.

Topics to Be Discussed in this Blog

  1. Why visualize Point Cloud Data?
  2. Difference Between Tools, Libraries, and Software
  3. Mostly used Tools and libraries for Point Cloud Visualization
  4. Point cloud visualization using Matplotlib and Open3D

On setting up Python libraries and environments for point cloud processing, refer my blog.

Why visualize Point Cloud Data?

Point cloud data can be involved as input for processing or output from processing during an application’s development. In both cases, visualizing the point cloud data can be mandatory or optional.

Point cloud data can be involved as input or output during various stages of an application’s development. Point cloud data visualization is Mandatory or Optional?

  • Planning phase: Visualization can be optional but used for:
    - Initial data exploration and understanding|
    - Defining processing requirements
  • Development phase: Visualization is often mandatory for:
    - Understanding 3D scene and objects in every stage of the development
    - Assessing data quality such as noisy, missing portion
    - Understanding features such as point density, color, normals
  • Production phase: Visualization is usually optional but used for:
    - Debugging and troubleshooting issues
    - Viewing the 3D data as part of the application itself

Different software tools or libraries are used for visualization depending on the specific needs and development environment.

Difference Between Tools, Libraries, and Software

  • Tools:
    - Tools are programs or software applications that perform specific tasks or functions.
    - e.g., MeshLab is a Tool
  • Libraries:
    - Libraries are collections of pre-written code or functions that can be used to perform specific tasks within a program or application.
    - e.g., Open3D and PCL are libraries
  • Software:
    - Software refers to a complete program or suite of programs that are designed to perform specific tasks or functions. Software is typically larger in scope than tools or libraries.
    - e.g., Unity3D is a Software

Mostly used Tools and libraries for Point Cloud Visualization

There are many tools and libraries designed for visualizing 3D point cloud data. Below are some of the most commonly used options:

1.Open3D: A powerful open-source library for 3D data processing and point cloud visualization.

https://www.open3d.org/

2. MeshLab: An open-source tool for processing and editing 3D triangular meshes and point clouds.

https://www.meshlab.net/

3. Unity 3D: A game development platform that can be used for interactive point cloud visualization.

https://unity.com/

4. PCL (Point Cloud Library): An open-source library for point cloud processing and visualization.

https://pointclouds.org/

5. Matplotlib: A open-source library can be used for basic point cloud visualization.

https://matplotlib.org/

A comparison of Point Cloud Visualization Tools and Libraries is shown in the table below

Comparison of Point Cloud Visualization Tools and Libraries

In this blog, you will explore how to visualize the point cloud data using Open3D and MeshLab.

Point cloud visualization using Matplotlib and Open3D

Here’s an python code using Open3D to load a ply file and visualize it using Matplotlib and Open3D.

"""
Visualizes a 3D point cloud from a PLY file using Matplotlib and Open3D.

Args:
- ply_file_path (str): The file path to the PLY file containing the
point cloud data.

Returns:
- None
"""

# Import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
import open3d as o3d

# Define the path to the PLY file
ply_file_path_read = "mug-only-vertices.ply"

# Load the point cloud data from the PLY file
pointcloud = o3d.io.read_point_cloud(ply_file_path_read)
pointcloud_array = np.asarray(pointcloud.points)

# Print the shape of the point cloud data
print(f"Point cloud details: {np.shape(pointcloud_array)}")

# Visualize the point cloud using Matplotlib
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(pointcloud_array[:, 0],
pointcloud_array[:, 1],
pointcloud_array[:, 2],
s=3,
c='blue',
alpha=1.0)

ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')
ax.set_zlabel('Z Axis')
plt.title('Sample Point cloud visualization using Matplotlib')
plt.show()

# Visualize the point cloud using Open3D
o3d.visualization.draw_geometries([pointcloud],
window_name='Sample Point cloud visualization using Open3D')
Output:
Point cloud Details: (1725, 3)

Below is the “mug-only-vertices.ply” file sample content used in the above program. The can be download from https://github.com/MatPixel/dataset-for-3d-pointcloud-processing-3d-deep-learning/blob/main/mug-only-vertices.ply

ply
format ascii 1.0
element vertex 1725
property float32 x
property float32 y
property float32 z
end_header
0.0474561 0.00671402 0.00774976
0.0476492 0.00711655 0.00771341
0.0468128 0.00536737 0.00784432
0.046762 0.00525942 0.00784425
0.0466932 0.00511251 0.00784099
0.0465647 0.00478846 0.00761509
0.0465471 0.00474429 0.00758437
0.0464256 0.00439643 0.00718348
0.0463905 0.00429643 0.00706995
0.0462817 0.00384311 0.00607561
0.0462155 0.00357221 0.00549328
0.0461564 0.00316135 0.00421748
0.0460851 0.00268506 0.00276459
0.0460872 0.00248846 0.00186518
0.0460892 0.00207614 6.26566e-09
0.0451128 0 6.26566e-09
0.0441269 0 -0.00937947

The following plots show the visualization using Matplotlib and Open3D. The plots use the default parameters of the libraries.

Visualization using Matplotlib
Visualization using Matplotlib

Summary

In this blog post we have examined the need of visualizing point cloud data and whether it is obligatory or optional in application development stages. Additionally, some popular tools and libraries for point cloud visualization were mentioned including Open3D and MeshLab followed by a practical example using Open3D along with Matplotlib to visualize.

Happy exploring! Happy learning!

📝Next Blog Preview:

In the upcoming post, 🚀“Mastering 3D Computer Vision & Point Cloud Processing- Mod 9 – Point Cloud to Mesh and Point Cloud to Voxel Grid Conversion with Code”.

Topics to Be Discussed in the Next Blog

  1. Introduction to 3D Data Types
  2. Why convert between different 3D Data Types
  3. Point Cloud to Mesh Conversion
  4. Point Cloud to Voxel Grid Conversion

Topics to Be Discussed in the Upcoming Blogs — Immediate Focus

  • Conversion between different Point Cloud data formats
  • Discussion on Commonly used File formats
  • Most used Dataset
  • Most Point Cloud Preprocessing Techniques

--

--

Rajavel PM (RPM)
Rajavel PM (RPM)

Written by Rajavel PM (RPM)

Computer Vision Engineer. Working on 3D computer vision, 3D machine learning & 3D Deep Learning, AI, and Generative AI. Let's learn together. Join Me!

No responses yet