Open3D 警告读取 PLY 失败:无法读取文件

问题描述 投票:0回答:3

我遇到了有关读取

.ply
文件的问题。我仔细检查了文件的路径是否正确。该代码会发出警告并继续运行。然而,对
cloud
变量的处理结果为空。

import open3d as o3d
cloud = o3d.io.read_point_cloud("aaa.ply")

[Open3D 警告]读取 PLY 失败:无法读取文件:aaa.ply
RPly:被用户中止

我正在使用Open3D的

0.17.0
版本。

更新:

链接至

.ply
文件。

python point-clouds open3d
3个回答
2
投票

您的

.ply
文件可能有问题,请尝试使用 此处 中的文件或与我们分享您的
aaa.ply
文件。

另外,你可以看看这个issue

编辑 在您提供 .ply 文件后,确实似乎抛出了该警告,但我可以访问点云中的点:

import open3d as o3d
import numpy as np
cloud = o3d.io.read_point_cloud('aaa.ply')
o3d.visualization.draw_geometries([cloud])
cloudPoints = np.asarray(cloud.points)

0
投票

我有一个类似但略有不同的错误:“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")

0
投票

修改后发现确实可以

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
© www.soinside.com 2019 - 2024. All rights reserved.