This simple scripts converts a file .obj acquired with the new Structure Sensor 3 to a file .ply compatible with Spot3D (i.e. colorized vertices and scale in mm).
Create a python environment and install the requirements
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Run the script (from the activated environment)
python obj2ply.py input.obj output.ply
output.ply
is an optional arguments. If it is missing the output will be input.ply
.
If you want to overwrite the output file add the flag -f
(or the equivalent --force
).
The usage is simple, but you can find a reminder of that in the help
>>> python obj2ply.py -h
____ ____ ___ _____ _____ ____
/ ___| | _ \ / _ \ |_ _||___ / | _ \
\___ \ | |_) || | | | | | |_ \ | | | |
___) || __/ | |_| | | | ___) || |_| |
|____/ |_| \___/ |_| |____/ |____/
_ _ ____ _
___ | |__ (_) |___ \ _ __ | | _ _
/ _ \ | '_ \ | | __) | | '_ \ | || | | |
_ | (_) || |_) | | | / __/ _ | |_) || || |_| |
(_) \___/ |_.__/ _/ | |_____| (_)| .__/ |_| \__, |
|__/ |_| |___/
usage: obj2ply.py [-h] [-f] [-v] input [output]
Convert obj file to colorized ply scaled in mm. Compatible with Spot3D.
positional arguments:
input the input .obj file
output the output .ply file. Default input.ply
optional arguments:
-h, --help show this help message and exit
-f, --force force to overwrite the output
-v, --verbose set verbose output
It is a simple python script which uses the pymeshlab library. The script is an adaptation of the very useful instruction on how to convert a .obj to .ply in meshlab.
- Load the .obj
- Scale the mesh from m to mm
- Centralize the mesh
- Rotate
- Subdivide the mesh
- Colorize the vertices
- Triangularize faces
- Export the .ply