Ray*_*Ray 5 python ply-file-format
我需要在Python中读取,操作和编写PLY文件。PLY是用于存储3D对象的格式。通过简单的搜索,我发现了两个相关的库PyMesh和 plyfile。有没有人对它们中的任何一个有任何经验,并且有任何建议吗?plyfile根据Github的判断,现在似乎已经休眠了一年。
我知道这个问题会激发基于意见的答案,但我真的不知道该问其他问题。
截至(2020 年 1 月)。
无,使用open3d。这是最简单的,可以将 .ply 文件直接读入 numpy。
import numpy as np
import open3d as o3d
# Read .ply file
input_file = "input.ply"
pcd = o3d.io.read_point_cloud(input_file) # Read the point cloud
# Visualize the point cloud within open3d
o3d.visualization.draw_geometries([pcd])
# Convert open3d format to numpy array
# Here, you have the point cloud in numpy format.
point_cloud_in_numpy = np.asarray(pcd.points)
Run Code Online (Sandbox Code Playgroud)
参考:
我在使用plyfilePointclouds时成功使用过。
的确,该对象很长时间没有呈现任何活动,但是符合其目的。
而且,事实并非像解析ply文件那样允许您通过添加新功能来重新创建自己。
另一方面,PyMesh除了解析层文件之外,还为您提供了许多其他功能。
所以也许问题是:
您是否只想“读取,操作和编写PLY文件”,还是正在寻找一个提供更多额外功能的库?
让我选择的plyfile是,只需复制1个源文件,便可以将其合并到我的项目中。另外,我对PyMesh提供的其他任何功能都不感兴趣。
我结束了编写自己的函数来读取/写入ply文件(支持ascii和二进制文件)的过程,因为我发现plyfile源代码有些混乱。
如果有人感兴趣,请访问以下文件链接: 层读取器/写入器
我刚刚更新了meshio以支持 PLY,以及大约 20 种其他格式。安装与
pip install meshio
Run Code Online (Sandbox Code Playgroud)
并在命令行上使用
meshio convert in.ply out.vtk
Run Code Online (Sandbox Code Playgroud)
或者从Python内部像
import meshio
mesh = meshio.read("in.ply")
# mesh.points, mesh.cells, ...
Run Code Online (Sandbox Code Playgroud)