首页 > 解决方案 > Complete a partial mesh and make it watetight

问题描述

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?

Partial mesh

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:

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.

CH+mesh

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.

标签: pythonmeshpartialtrimesh

解决方案


我会查看pyvista示例页面,他们有一个很好的pyvista.wrap功能可以让您从trimeshpyvista,然后您可以使用pv_obj.points设置顶点并pv_obj.faces.reshape(-1, 4)[:, 1:]返回到trimesh。有些操作会带你PolyData进入一个UnstructedGrid类,但只要它们是三角形,这些线就可以工作。Trimesh 速度非常快,他是回答 github 问题的摇滚明星,但pyvista. 为了我的项目,我必须不断地在两者之间跳跃。

这是我正在考虑的相关示例:https ://docs.pyvista.org/examples/01-filter/resample.html

拉回trimesh. _

trimesh还将 Open3D 列为可选依赖项,它具有更好的点云重建算法,但我还没有充分利用它来推动您获得它的资源。


推荐阅读