[英]Using just vertices to generate faces in PyMeshLab
I have an array of vertices representing some 3D point cloud, and I would like to import this into PyMeshLab to generate faces for the object (sort of like generating a convex hull, but if the 3D object were vertices of a human's hand, it would wrap around each finger correctly). I have an array of vertices representing some 3D point cloud, and I would like to import this into PyMeshLab to generate faces for the object (sort of like generating a convex hull, but if the 3D object were vertices of a human's hand, it would正确环绕每个手指)。 Does PyMeshLab (or other libraries) offer this functionality?
PyMeshLab(或其他库)是否提供此功能? The below code of usually doing it using a
.obj
that has both vertices and faces works, but not so when given something with just vertices.下面的代码通常使用同时具有顶点和面的
.obj
来执行此操作,但在仅给出顶点的情况下并非如此。
ms = pymeshlab.MeshSet()
ms.load_new_mesh('vertices.npy')
ms.generate_surface_reconstruction_ball_pivoting()
ms.save_current_mesh('vertices.obj')
# get a reference to the current mesh
m = ms.current_mesh()
# get numpy arrays of vertices and faces of the current mesh
v_matrix = m.vertex_matrix()
f_matrix = m.face_matrix() # <- I would like to generate this, but I'm not allowed so with just a faces input
The PyVista library does that for sure. PyVista库确实可以做到这一点。 Honestly, I don't know if MeshLab can do that as well, I have to check that.
老实说,我不知道 MeshLab 是否也能做到这一点,我必须检查一下。
As an example, let's consider the Standford bunny.例如,让我们考虑一下斯坦福兔。 I have imported its mesh and got its vertices.
我已经导入了它的网格并得到了它的顶点。 The
reconstruct_surface
method did the trick. reconstruct_surface
方法成功了。 You have to tweak the method's parameters to get the desired result.您必须调整方法的参数以获得所需的结果。 For further details look here .
更多详情请看这里。
import pyvista as pv
bunny = pv.read("Stanford_Bunny.ply")
points = pv.wrap(bunny.points)
surf = points.reconstruct_surface(nbr_sz=10)
pl = pv.Plotter(shape=(1, 2))
pl.add_mesh(points)
pl.add_title("Point Cloud of 3D Surface")
pl.subplot(0, 1)
pl.add_mesh(surf, color=True, show_edges=True)
pl.add_title("Reconstructed Surface")
pl.show()
If you just wanted the convex hull check this scipy method .如果您只想要凸包,请检查此scipy 方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.