【问题标题】:How do I convert a 3D point cloud (.ply) into a mesh (with faces and vertices)?如何将 3D 点云 (.ply) 转换为网格(带有面和顶点)?
【发布时间】:2019-11-19 18:14:35
【问题描述】:

我有一个包含 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'

【问题讨论】:

  • 我相信我正在接近这个错误。也许德劳内三角测量不能很明显地做到这一点。
  • 基于open3d-python==0.0.7.0: 1. o3d.PointCloud 没有points 而是vertices。所以np.array(pointcloud.points) 不应该工作。 2. 与open3d 不同,trimesh 不会加载没有人脸的点云。您可以人为地添加一张脸并再次保存,以便您可以使用 trimesh 加载它(通过使用 open3d 加载、添加、保存 - 或直接编辑文件并添加假脸)。

标签: python mesh point-clouds delaunay trimesh


【解决方案1】:

Open3d 0.8.0.0 现在已实现 rolling ball pivoting algorithm 以从点云重建网格。

我使用以下方法解决了从点云生成三角网格的问题:

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)

【讨论】:

  • 如果我有一个彩色点云,你知道我可以用什么方法来纹理这个网格吗?
  • 您好,您如何保存结果网格?
【解决方案2】:

只是询问这行代码实际上做了什么?它将点云函数调用为pcd,但是双向量截面是什么意思呢? - o3d.utility.DoubleVector([radius, radius * 2]))

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

【讨论】:

    猜你喜欢
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    相关资源
    最近更新 更多