python点云处理模块_python处理点云数据并生成三维点云模型

1.python代码:

1 importnumpy as np

2 importmatplotlib.pyplot as plt

3 from mpl_toolkits.mplot3d importAxes3D

4 #f=open('point cloud.txt','r')

5 f=open('11D-zhongxin1-1_RawXYZ_ds_part2.xyz','r')

6 point=f.read() 7 f.close() 8 l1=point.replace('\n',',') 9 l2=l1.split(',') 10 l2.pop() 11 #print(l2) 12 m1=np.array(l2[0:120000]) 13 print(len(m1)) 14 #m2=m1.reshape(265565,4) 15 m2=m1.reshape(30000,4) 16 print(m2) 17 m3=[] 18 for each inm2: 19 each_line=list(map(lambdax:float(x),each)) 20 m3.append(each_line) 21 m4=np.array(m3) 22 23 x=[k[0] for k inm4] 24 y=[k[1] for k inm4] 25 z=[k[2] for k inm4] 26 27 fig=plt.figure(dpi=120) 28 ax=fig.add_subplot(111,projection='3d') 29 plt.title('point cloud') 30 ax.scatter(x,y,z,c='b',marker='.',s=2,linewidth=0,alpha=1,cmap='spectral') 31 32 #ax.set_facecolor((0,0,0)) 33 ax.axis('scaled') 34 # ax.xaxis.set_visible(False) 35 # ax.yaxis.set_visible(False) 36 ax.set_xlabel('X Label') 37 ax.set_ylabel('Y Label') 38 ax.set_zlabel('Z Label') 39 plt.show()

2.运行结果如下:

e6ed870d5e426c269207faefd82b2de4c82.png

3.点云的数据格式如下(1-15),其中前三列为x,y,z的坐标,我们取用前三列,第四列可以忽略:

658660.61,4231154.24,-13.69,-13.690001

658660.21,4231154.44,-14.12,-14.120000

658660.41,4231154.44,-14.02,-14.025000

658660.61,4231154.44,-14.19,-14.195000

658660.81,4231154.44,-14.13,-14.132500

658661.01,4231154.44,-14.16,-14.160000

658661.21,4231154.44,-13.94,-13.935000

658660.21,4231154.64,-14.07,-14.073333

658660.41,4231154.64,-14.13,-14.127778

658660.61,4231154.64,-14.15,-14.155000

658660.81,4231154.64,-14.06,-14.055000

658661.01,4231154.64,-13.98,-13.977500

658661.21,4231154.64,-13.81,-13.805000

658661.61,4231154.64,-13.94,-13.940000

658660.01,4231154.84,-14.15,-14.150000

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值