Skip to content

Python tool to compute the envelope (alpha shape) of a 3D point cloud, save it and save some related metrics.

License

Notifications You must be signed in to change notification settings

cyrilbz/envelope_cloud

Repository files navigation

envelope_cloud

Python tool to compute the envelope (alpha shape) of a 3D point cloud, save it as .obj, and save some related metrics (volume and area of the alpha shape, projected area on the ground, accuracy of the alpha shape, number of envelopes) in a csv file.

Only .txt files are supported as inputs for now but this can be improved with some minor modifications.

The code relies on:

  • Open3d for point cloud manipulation, 3d alpha shape creation, and (optional) visualisation,
  • PyVista for mesh/point cloud intersection and 2d mesh creation,
  • PyMeshFix for alpha shape mesh repair.

Example

Below are two example images demonstrating the functionality of the project:

Description of Image 1

Input point cloud that has been downsampled at the given sampling_ratio value.

Description of Image 2

Resulting alpha-shape for a given alpha value, along with the projected surface on the ground.

The code outputs in the console and in the output file the alpha value, the alpha shape volume and area, the projected surface on the ground, the accuracy of the alpha shape regarding the point cloud (checks the ratio of points inside the envelope to the full set of points), and the number of meshes in case of multiple envelopes.

Usage

After installing the code (see instructions below), you can run it as you want by modifying the following parameters in the main program (envelope_cloud.py):

########################## Inputs ##############################
# relative or absolute path to the directory containing files to study
directory = './test_data' 
alpha=0.3
minimal_distance = 0.035 # voxel size for downsampling by voxelisation
output_file_name = 'results.csv' # written in "directory"
plot_results = False # option to plot results using open3d
################################################################

Do not forget to activate your dedicated conda environment (see instructions below),

conda activate envelope

then run the code !

python envelope_cloud.py

Installation

To install and set up the project, follow these steps:

Prerequisites

Ensure you have the following installed on your system:

  • Git
  • A free Python packages & environment manager (e.g., Miniforge)

Step-by-Step Guide

  1. Clone the Repository

    Open a terminal (or Anaconda prompt on Windows) and run the following command to clone the repository:

    git clone git@github.com:cyrilbz/envelope_cloud.git
  2. ** Move to the directory, create a dedicated Conda environement, and install all requirements**

    cd envelope_cloud
    
    conda create --name envelope python=3.12.0
    
    conda activate envelope
    
    pip install -r requirements.txt
  3. LINUX USERS You might have to install an additional library to have the open3d viewer option to work:

    conda install -c conda-forge libstdcxx-ng
  4. Modify the input parameters as you want and run the code!

    python envelope_cloud.py

About

Python tool to compute the envelope (alpha shape) of a 3D point cloud, save it and save some related metrics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages