我遇到了有关读取
.ply
文件的问题。我仔细检查了文件的路径是否正确。该代码会发出警告并继续运行。然而,对 cloud
变量的处理结果为空。
import open3d as o3d
cloud = o3d.io.read_point_cloud("aaa.ply")
[Open3D 警告]读取 PLY 失败:无法读取文件:aaa.ply
RPly:被用户中止
我正在使用Open3D的
0.17.0
版本。
更新:
.ply
文件。
我有一个类似但略有不同的错误:“open3d .ply Read PLY failed: no vertex attribute”,所以这可能对您有帮助。我使用的 .ply 文件是 DALES 激光雷达数据集的一部分。 Open3d 预计文件显然具有名为“vertex”和“face”的元素。我发现我的 .ply 文件标题中有名为“testing”的元素。
如何检查元素类型 在文本编辑器中打开文件,或者仅使用命令行查看前 10 行左右
里面:
ply
format binary_little_endian 1.0
element testing 11331760 # This needs to be "vertex" or "face" not "testing"
property float x
property float y
property float z
property int intensity
property int sem_class
property int ins_class
end_header
您也许可以手动输入并保存。我有几个文件需要更改,因此使用此代码将所有元素转换为“顶点”。如果混合使用顶点和面,这会很糟糕。我的数据是点云,所以一切都是顶点。
更改元素类型
使用 python 将单个文件转换为类型“vertex”:
from plyfile import PlyData, PlyProperty, PlyElement
from pathlib import Path
# read in file
data = PlyData.read("orig_file.ply")
# make a new PlyElement with type "vertex" with our existing data
renamed_element = PlyElement.describe(data.elements[0].data, 'vertex',
comments=[f'Renamed from: {data.elements[0].name}'])
# Make a new PlyData object of binary format
fixed_data = PlyData([renamed_element], text=to_ascii)
# Write it out
fixed_data.write("Fixed_file.ply")
修改后发现确实可以
ply
format binary_little_endian 1.0
element vertex 164397
comment Renamed from: params
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property char label_ch
property char label_mono
end_header