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

huangapple go评论368阅读模式
英文:

Open3D WARNING Read PLY failed: unable to read file

问题

我在读取.ply文件方面遇到了问题。我已经确认文件路径是正确的。代码会引发警告并继续运行。然而,在cloud变量上进行的处理结果为空。

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

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

我正在使用Open3D的版本0.17.0

更新:

链接到.ply文件

英文:

I'm facing an issue regarding reading .ply files. I double-checked that the file's path is correct. The code raises a warning and continues running. However, the results of the processing made on the cloud variable empty.

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

> [Open3D WARNING] Read PLY failed: unable to read file: aaa.ply
RPly: Aborted by user

I'm using the version 0.17.0 of Open3D.

Update:

Link to the .ply file.

答案1

得分: 2

这是您要翻译的部分:

  • "It might be a problem with your .ply file, try with one from here or share your aaa.ply file with us."
  • "Also, you can have a look at this issue."
  • "EDIT After you provided the .ply file, indeed it seems to be throwing that warning, but I can access the points in the point cloud:"
  • "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)"

请注意,其中的HTML标签已经被移除,以保持文本的清晰度。

英文:

It might be a problem with your .ply file, try with one from here or share your aaa.ply file with us.

Also, you can have a look at this issue.

EDIT
After you provided the .ply file, indeed it seems to be throwing that warning, but I can access the points in the point cloud:

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

答案2

得分: 0

我遇到一个类似但略有不同的错误:“open3d .ply Read PLY failed: no vertex attribute”,所以这可能对你有帮助。我使用的.ply文件是DALES激光雷达数据集的一部分。Open3d期望文件中的元素名称为“vertex”和“face”。我发现我的.ply文件的元素名称在头部中是“testing”。

如何检查元素类型
打开文件编辑器,或者使用命令行查看前10行左右

在文件内:

  1. ply
  2. format binary_little_endian 1.0
  3. element testing 11331760 # 这应该是“vertex”或“face”,而不是“testing”
  4. property float x
  5. property float y
  6. property float z
  7. property int intensity
  8. property int sem_class
  9. property int ins_class
  10. end_header

你可以手动输入并保存。我有几个文件要更改,所以使用了以下代码将所有元素转换为“vertex”。如果你的文件同时包含顶点和面,这可能不适用。我的数据是点云,所以一切都是顶点。

更改元素类型
要使用Python将单个文件转换为“vertex”类型:

  1. from plyfile import PlyData, PlyProperty, PlyElement
  2. from pathlib import Path
  3. # 读取文件
  4. data = PlyData.read("orig_file.ply")
  5. # 使用我们现有的数据创建一个新的PlyElement,类型为“vertex”
  6. renamed_element = PlyElement.describe(data.elements[0].data, 'vertex',
  7. comments=[f'Renamed from: {data.elements[0].name}'])
  8. # 创建一个新的二进制格式的PlyData对象
  9. fixed_data = PlyData([renamed_element], text=to_ascii)
  10. # 将其写出
  11. fixed_data.write("Fixed_file.ply")
英文:

I had a similar but slightly different error: "open3d .ply Read PLY failed: no vertex attribute", so this may help you. The .ply file I was using was part of the DALES lidar dataset. Open3d expects the files have elements named "vertex" and "face" apparently. I found that my .ply files had elements named "testing" in the header.

How to check element types
Open the file in a text editor, or just use command line to see the top 10 or so lines

Inside :
<!-- language: text-->
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

You may be able to manually type and save it. I had several files to change, so used this code to convert all elements to "vertex". This would be bad if you had a mix of vertexes and faces. My data are pointclouds, so everything is a vertex.

Change element types

To convert a single file to type "vertex" with python:

<!-- language: python -->
from plyfile import PlyData, PlyProperty, PlyElement
from pathlib import Path

  1. # read in file
  2. data = PlyData.read(&quot;orig_file.ply&quot;)
  3. # make a new PlyElement with type &quot;vertex&quot; with our existing data
  4. renamed_element = PlyElement.describe(data.elements[0].data, &#39;vertex&#39;,
  5. comments=[f&#39;Renamed from: {data.elements[0].name}&#39;])
  6. # Make a new PlyData object of binary format
  7. fixed_data = PlyData([renamed_element], text=to_ascii)
  8. # Write it out
  9. fixed_data.write(&quot;Fixed_file.ply&quot;)

huangapple
  • 本文由 发表于 2023年3月15日 18:52:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743702.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定