KITTI Velodyne Point Cloud-激光雷达点云bin文件读取和显示
程序员文章站
2022-04-17 17:46:48
...
参考:http://ronny.rest/tutorials/module/pointclouds_01 |
---|
点云数据的介绍 |
图像和点云坐标系 |
点云鸟瞰图生成 |
点云360°全视图 |
基于Mayavi的交互式三维可视化 |
基于Matplotlib的交互式三维可视化 |
代码
import mayavi.mlab
import torch
import numpy as np
mypointcloud=np.fromfile("/home/zzn/Documents/test/lidar/000002.bin",dtype=np.float32,count=-1).reshape([-1,4])
mypointcloud=torch.from_numpy(mypointcloud)
print(mypointcloud.size())
print(mypointcloud.type())
def viz_mayavi(points,vals="distance"):
x=points[:,0]
y=points[:,1]
z=points[:,2]
r=points[:,3]
d=torch.sqrt(x**2+y**2)
if vals=="height":
col=z
else:
col=d
fig=mayavi.mlab.figure(bgcolor=(0,0,0),size=(1280,720))
mayavi.mlab.points3d(x,y,z,
col,
mode="point",
colormap='spectral',
figure=fig,
)
mayavi.mlab.show()
if __name__=="__main__":
viz_mayavi(mypointcloud,vals="height")
结果
torch.Size([115604, 4])
torch.FloatTensor