python - 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?
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.
解决方案
我会查看pyvista
示例页面,他们有一个很好的pyvista.wrap
功能可以让您从trimesh
到pyvista
,然后您可以使用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 列为可选依赖项,它具有更好的点云重建算法,但我还没有充分利用它来推动您获得它的资源。
推荐阅读
- linux - 使用服务在 .bash 中启动 .sh 或在服务中启动 .sh 文件
- typescript - 异步函数需要 Visual Studio 2019 中的“Promise”构造函数
- curity - 如何确定多久前在 Curity 中发布了刷新令牌
- python - python装饰器包装两次?
- xcode - XCode 12.1 自动完成和 TextHighliting 错误?
- python - 为什么我不能使用“as”语法在 Python 中导入函数?
- laravel-nova - Laravel Nova 中另一个表的字段
- node.js - 如何重写成json文件nodejs?
- javascript - 如何找到垂直于线中点的点的 3D 坐标
- linux - 连接多个具有相同 HEADER 格式的数据集