我正在处理一个项目,该项目需要以 .ply 文件的形式访问点云数据并将它们转换为 numpy 数组以运行深度学习算法。当我尝试从我的目录访问我的 .ply 文件时,我收到错误“ValueError:两个具有相同名称的属性”
以下是我的代码 -
import glob
import numpy as np
from plyfile import PlyData, PlyElement
arr = np.array([])
for filepath in glob.iglob('/content/drive/My Drive/PLY Files/*.ply'):
plyFile = PlyData.read(filepath)
plyFile.elements[0].properties
以下是错误(此处仅转载相关部分) -
ValueError Traceback (most recent call last)
<ipython-input-42-4464816991de> in <module>()
4
5 for filepath in glob.iglob('/content/drive/My Drive/PLY Files/*.ply'):
----> 6 plyFile = PlyData.read(filepath)
7 plyFile.elements[0].properties
/usr/local/lib/python3.6/dist-packages/plyfile.py in _index(self)
549 for prop in self._properties)
550 if len(self._property_lookup) != len(self._properties):
--> 551 raise ValueError("two properties with same name")
552
553 def ply_property(self, name):
ValueError: two properties with same name
我的 ply 文件 - 部分复制了顶点(由 pcl 使用pcl_pcd2ply命令生成):
ply
format ascii 1.0
comment PCL generated
element vertex 92928
property float x
property float y
property float z
property list uint uchar _
property float intensity
property list uint uchar _
element camera 1
property float view_px
property float view_py
property float view_pz
property float x_axisx
property float x_axisy
property float x_axisz
property float y_axisx
property float y_axisy
property float y_axisz
property float z_axisx
property float z_axisy
property float z_axisz
property float focal
property float scalex
property float scaley
property float centerx
property float centery
property int viewportx
property int viewporty
property float k1
property float k2
end_header
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 4 0 0 128 63 0 12 0 0 0 0 0 0 0 0 0 0 0 0