Skip to content

Python scripts for converting mesh formats, mesh simplification and mesh rigid transformation

Notifications You must be signed in to change notification settings

issacchan26/mesh-processing

Repository files navigation

Mesh processing

This repo is to provide a series of algorithm to process mesh and point cloud files.
It provides format transfer, mesh simplification, mesh rigid transform and point cloud (.PCD) annotation transform

Getting Started

Use the pip to install dependencies, you may use conda instead
For PyTorch3D, please follow this link to install: https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md

pip install numpy
pip install pandas
pip install pymeshlab
pip install open3d

Usage

Create the corresponding folder before you run the script.
For example, in mesh simplification, you need to create two folders: "mesh_data" and "output_mesh"
Make sure the directories are created as below:

├── mesh_data
│   ├── 1_139.obj
│   ├── 1_141.obj
├── output_mesh
└── mesh_reduce.py

Mesh simplification

reduce the mesh to target vertices
You may adjust the the number of vertices by changing the parameter TARGET (default=10000)

Mesh format convert

obj to pcd format
obj to ply format

Convert txt file into obj mesh

txt to obj format
xyz to obj format

Mesh rigid transform

Currently we suppor .obj format as input for meshes

mesh augmentation provides three functions for mesh augmentations:rotation, translation and scaling.
shrink and fatten provides the Blender function: "shrink and fatten", to change the shape of meshes by moving selected vertices along their own normal (perpendicular to the face)

Point cloud annotation operation

output the annotation to simplified txt
add rgb value into ply file
Please refer to point-cloud-annotation for more details

Invisible spaces in .ply file

For each ply file generated, there maybe some spaces randomly generated by the library. It may cause the ply file cannot be read.
To remove the spaces, please run following code with terminal inside the folder:

sed -i 's/[ \t]*$//' *.ply