读取ply文件中的点云属性
通过open3d只能读取xyz坐标,对于ply中存储的其他点云属性字段,比如法向量、强度、颜色等等则不能很好的读取。因此参考了相关代码实现了点云属性的读取,代码如下:
import numpy as npdef read_ply(infile, limit_points=0, move_to_origin=False, read_normals=True):"""collect vertex coordinates and normals from input file"""ox,oy,oz = (0,0,0)datadict = {}with open(infile) as f:vertexcount = facecount = Noneproperty_dict = {}property_count = 0while True:line = f.readline()if line.startswith("element vertex"):vertexcount = line.split()[-1]while True:line = f.readline()prev_cursor_pos = f.tell()if line.startswith("property"):property_name = line.spl