I am capturing point clouds from a RealSense camera and converting them into meshes using the Trimesh library. The issue is that I only get a non-watertight mesh from this. How do I "finish" the mesh and make it watertight?
I tried
trimesh.repair.broken_faces(mesh, color=[255, 0, 0, 255])
but that didn't seem to fully help. I tried creating a convex hull:
and tried to perform a union between the two, but that died with:
ipdb> mesh.union(ch,engine='scad')
*** subprocess.CalledProcessError: Command '['/usr/bin/openscad', '/tmp/tmpqrdvbdd2', '-o', '/tmp/tmpvdzjmkgm.off']' returned non-zero exit status 1
ipdb> mesh.union(ch,engine='blender')
*** subprocess.CalledProcessError: Command '['/usr/bin/blender', '--background', '--python', '/tmp/tmp9_5phhhj']' returned non-zero exit status 127
and I would also lose the RGB information from the source mesh. How do I complete the mesh using a convex hull, yet retain all the known RGB values?
Edit: I moved the needle a little more. I looked at the face normals of the convex hull, and extracted all those that were pointed to the side and down. I created a new mesh with the old mesh vertices and the faces defined by the old faces + the new ones from the convex hull.
This gets me closer to my goal, but now I have a bunch of holes that neither trimesh.repair.fill_holes nor meshlab's filter is giving me good results.
The
trimesh.PointCloud
class has the "property"convex_hull
.Quoting the trimesh docs:
Does this do what you want?