gpt4 book ai didi

python - Python:从点云创建3D网格/曲面

转载 作者:太空宇宙 更新时间:2023-11-03 19:54:21 31 4
gpt4 key购买 nike

关于从Python中的点云进行3D网格重建的问题,有几个主题。通常,当X,Y,Z坐标可用并且不存在体积表示时,通过激光扫描获取。我已经尝试了许多库:


matplotlib,
mayavi,
open3D,
阴谋地
pcl,


等等,但结果相对较差。其中一些插图如下。

让我们仔细看一下说明性示例-源datadownload text file here)表示存储为X,Y,Z坐标文本文件的建筑物的一部分(角+屋顶):

enter image description here

我从matplotlib库开始工作:

 def drawMesh(x, y, z):
fig = plt.figure(figsize=plt.figaspect(0.5))
min_radius = 0.25
triang = mtri.Triangulation(x, y)
xmid = x[triang.triangles].mean(axis=1)
ymid = y[triang.triangles].mean(axis=1)
mask = np.where(xmid ** 2 + ymid ** 2 < min_radius ** 2, 1, 0)
triang.set_mask(mask)
ax = fig.add_subplot(1, 2, 2, projection='3d')
ax.plot_trisurf(triang, z)
plt.show()


但是,它仅使用2D Delaunay三角剖分。结果在这里:
  enter image description here

第二次尝试导致了mayavi库。 2D三角剖分

def drawMesh(x, y, z):
mlab.figure(1, fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
pts = mlab.points3d(x, y, z, z, scale_mode='none', scale_factor=0.2, extent=[0, 1, 0, 1, 0, 1])
mesh = mlab.pipeline.delaunay2d(pts)
surf = mlab.pipeline.surface(mesh)
mlab.show()


遭受同样的问题:

enter image description here

不幸的是,替代了3D Delaunay

 mesh = mlab.pipeline.delaunay3d(pts)


仅生成凸包:

enter image description here

open3D库,它使用球透视算法:

def drawMesh(file_txt):
pcd = o3d.io.read_point_cloud(file_txt, format='xyz')
pcd.estimate_normals()
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]))
trimesh = trimesh.Trimesh(np.asarray(mesh.vertices), np.asarray(mesh.triangles), vertex_normals=np.asarray(mesh.vertex_normals))
trimesh.show()


提供带有孔的相对稀疏的三角形表面:

enter image description here

我的问题是:


当不存在体积表示时,是否有任何Pythonic库(或Python绑定)支持从点云(坐标X,Y,Z)更好地重建网格?
否则,是否有任何其他库可能比上述尝试更好?
否则,任何人都可以使用任何其他(可用)软件来获得附加数据的更好结果吗?我尝试了云比较和Meshlab,但是输出比预期的要差。


CGAL可能看起来很有前途,但其安装和配置并不容易...

抱歉,我冗长的帖子,感谢您的帮助。

最佳答案

原则上不可能仅根据点信息来创建卷,因此将没有库可以做到这一点。

作为一个简单的例子,请考虑以下几点



应该在什么区域? 3D中存在相同的问题。

关于python - Python:从点云创建3D网格/曲面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59628420/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com