Why do I get, ValueError: two properties with same name when I try to access .ply files using plyfile API?

烈酒焚心 提交于 2019-12-11 14:31:40

问题


I am working with a project that requires accessing point cloud data in the form of .ply files and converting them into numpy arrays for running a deep learning algorithm. When I try to access my .ply files from my directory, I get the error "ValueError: two properties with same name"

The following is my code -

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

The following is the error (only relevant portions reproduced here) -

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

My ply file - vertices are partially reproduced (generated by pcl using pcl_pcd2ply command) :

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

来源:https://stackoverflow.com/questions/58183252/why-do-i-get-valueerror-two-properties-with-same-name-when-i-try-to-access-pl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!