如何将所有点从.pcd文件导入到2d python数组中

时间:2019-06-28 16:00:19

标签: python-3.x point-cloud-library

如何从名为edge_cloud.pcd的文件中导入所有3d点并将它们放入数组中?我希望数组的格式为

array=[[xvalue1,yvalue1,zvalue1],[xvalue2,yvalue2,zvalue2]] 

1 个答案:

答案 0 :(得分:1)

使用Python 3.7.3,numPy 1.16.2和open3d 0.7.0.0进行了测试:

import numpy as np 
import open3d as o3d

pcd = o3d.io.read_point_cloud("C:\\Users\\Username\\Source\\pointcloud\\bunny.pcd")
out_arr = np.asarray(pcd.points)  
print ("output array from input list : ", out_arr)  

输出:

output array from input list :  
[[ 0.0054216  0.11349    0.040749 ]
 [-0.0017447  0.11425    0.041273 ]
 [-0.010661   0.11338    0.040916 ]
 ...
 [-0.064992   0.17802   -0.054645 ]
 [-0.069935   0.17983   -0.051988 ]
 [-0.07793    0.17516   -0.0444   ]]

输入PCD文件:

https://github.com/PointCloudLibrary/pcl/blob/master/test/bunny.pcd