使用 matlab 打开 .ply 网格文件(或在 python 中转换为可读格式)

open .ply mesh files with matlab (or convert to readable format in python)

我正在使用 MPI FAUST 数据集 - 包含 .ply 个网格文件。
.ply headers 如下:

ply
format binary_little_endian 1.0
element vertex 6890
property float x
property float y
property float z
element face 13776
property list uchar int vertex_indices
end_header

而且我能够使用 pymesh 库加载它们:

a =  pymesh.load_mesh("tr_scan_019.ply")
a.vertices
array([[ 0.00294954,  0.3746013 , -0.18593594],
       [-0.01065227,  0.30154902,  0.03721469],
       [ 0.01176361,  0.37961864, -0.18658873],
       ...,
       [ 0.39272201,  1.0824883 ,  0.0319973 ],
       [-0.29185328,  1.00391781,  0.03810745],
       [ 0.39623857,  1.08823442,  0.03612268]])
>>> a.faces
array([[ 49533,  45416,  52207],
       [141371,  38353,  56906],
       [ 57747,  59888,  43636],
       ...,
       [132845, 180118, 175435],
       [166162, 173001, 166963],
       [177654, 173001, 166162]], dtype=int32)

我需要将它们加载为可读的 matlab 网格格式,因为我有在 matlab 中编写的网格处理函数。

我尝试使用 matlab 函数加载它们,但都是 2015 年的,并且没有用(例如 gptoolbox 只读取顶点)。
有没有办法将网格写入可读的 matlab 格式,以便我以后可以在 matlab 中正确读取它?

您可以使用 meshio(我的一个项目)将 ply 文件转换为一系列其他格式,也许其中一种格式在 MATLAB 中是本机可读的。刚刚

pip3 install meshio --user

然后

meshio-convert in.ply out.vtk

在命令行上。

如果这不起作用,您可以从 Python、

中将数据转储到简单的文件中,例如 csv
import meshio

mesh = meshio.read("in.ply")
# mesh.points, mesh.cells, ...