Setup env

Download dataset

<aside> 💡 Remember to select the created environment for this project, using conda, for both terminal and jupyter notebook

</aside>

Initial dependencies

For getting a 3D mesh automatically out of a point cloud, we will add another library to our environment, Open3D. It is an open-source library that allows the use of a set of efficient data structures and algorithms for 3D data processing.

The Open3d requires other 3 packages: plyfile, sklearn and addict. So, we need to install them all:

Preparing our data

First, we're going to import our libraries for data structure managing.

import numpy as np
import open3d as o3d

Then, we create variables that hold data paths and the point cloud data:

input_path="your_path_to_file/"
output_path="your_path_to_output_folder/"
dataname="sample_w_normals.xyz"
point_cloud= np.loadtxt(input_path+dataname,skiprows=1)

Finally, we transform our point_cloud variable type from Numpy to the Open3D o3d.geometry.PointCloud type (for further processing):

pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(point_cloud[:,:3])
pcd.colors = o3d.utility.Vector3dVector(point_cloud[:,3:6]/255)
pcd.normals = o3d.utility.Vector3dVector(point_cloud[:,6:9])

<aside> 💡 The following command first instantiates the Open3d point cloud object, then add points, color and normals to it from the original NumPy array.

</aside>

For a quick visual of what you loaded, you can execute the following command (does not work in Google Colab):

o3d.visualization.draw_geometries([pcd])