如何将 3D 点云 (.ply) 转换为网格(具有面和顶点)?

新手上路,请多包涵

我有一个包含 100 万个点的 3-D 点云文件,我需要将其转换为 trimesh 中的网格文件。这里的最终目标是获取点云并确定该点云是凸的还是凹的(一旦我将点云转换为网格,trimesh 允许我这样做)。我对其他图书馆开放来解决这个问题。

我已经尝试使用 scipy 进行 Delaunay 三角剖分,但似乎无法将我的点云转换为正确的格式,以便 trimesh 可以读取它。

 import open3d as o3d
import numpy as np
import trimesh
from scipy.spatial import Delaunay

pointcloud = o3d.io.read_triangle_mesh("pointcloud.ply")
points = np.array(pointcloud.points)
triangle_mesh = Delaunay(points)
#  How do i include triangle_mesh from Delaunay triangulation into processing the mesh file?
mesh = trimesh.load("pointcloud.ply")
print(trimesh.convex.is_convex(mesh))

错误

geometry::TriangleMesh appears to be a geometry::PointCloud (only contains vertices, but no triangles).
geometry::TriangleMesh with 1390073 points and 0 triangles.
expected = (faces.shape[0], faces.shape[1] * 2)
AttributeError: 'NoneType' object has no attribute 'shape'

原文由 Vishal 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.6k
1 个回答

Open3d 0.8.0.0 现在已经实现了 滚球旋转算法 来从点云重建网格。

我使用以下方法解决了从点云生成 trimesh 的问题:

 import open3d as o3d
import trimesh
import numpy as np

pcd = o3d.io.read_point_cloud("pointcloud.ply")
pcd.estimate_normals()

# estimate radius for rolling ball
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist

mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(
           pcd,
           o3d.utility.DoubleVector([radius, radius * 2]))

# create the triangular mesh with the vertices and faces from open3d
tri_mesh = trimesh.Trimesh(np.asarray(mesh.vertices), np.asarray(mesh.triangles),
                          vertex_normals=np.asarray(mesh.vertex_normals))

trimesh.convex.is_convex(tri_mesh)

原文由 chrissi_gsa 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题