简体   繁体   English

在 PyMeshLab 中仅使用顶点生成面

[英]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.

相关问题 如何在pymeshlab中选择顶点数组? - How to select an array of vertices in pymeshlab? 使用来自 python 的 pymeshlab,如何获取过滤器 compute_selection_by_self_intersections_per_face() 选择的面孔? - Using pymeshlab from python, how to get the faces selected by the filter compute_selection_by_self_intersections_per_face()? 如何创建vtk七角棱镜(7个面有4个顶点,2个面有7个顶点) - How to create vtk heptagonal prism (7 faces with 4 vertices and 2 faces with 7 vertices) 绘制存储为顶点和面的网格 - Plot mesh stored as vertices and faces Blender Python api 顶点、边和面选择 - Blender Python api vertices, edges and faces selection 在 OpenMesh 中读取相邻顶点和面的问题 - Problem with reading neighboring vertices and faces for a vertex in OpenMesh Pyinstaller 和 Pymeshlab - Pyinstaller and Pymeshlab 准确计算Python中Wavefront .obj文件中的顶点和面的总数? - Calculate accurately the total number of vertices and faces in Wavefront .obj file in Python? 如何从对象面的顶点信息创建collada文件? - How to create a collada file from an objects faces' vertices information? 给定一组三角形顶点和面,分离对象并形成单独的网格 - Given a set of triangle vertices and faces, separate objects and form separate meshes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM