【KITTI数据集】VELODYNE POINT CLOUD-激光雷达点云BIN文件读取和显示-OPEN3D

1、在anaconda环境下:

conda install -c open3d-admin open3d

缺少其他模块的话,pip安装就可以

2、点云的读取和显示

import os
import numpy as np
import struct
import open3d

def read_bin_velodyne(path):
    pc_list=[]
    with open(path,'rb') as f:
        content=f.read()
        pc_iter=struct.iter_unpack('ffff',content)
        for idx,point in enumerate(pc_iter):
            pc_list.append([point[0],point[1],point[2]])
    return np.asarray(pc_list,dtype=np.float32)

def main():
    root_dir='data/'
    filename=os.listdir(root_dir)
    file_number=len(filename)

    pcd=open3d.open3d.geometry.PointCloud()

    for i in range(file_number):
        path=os.path.join(root_dir, filename[i])
        print(path)
        example=read_bin_velodyne(path)
        # From numpy to Open3D
        pcd.points= open3d.open3d.utility.Vector3dVector(example)
        open3d.open3d.visualization.draw_geometries([pcd])

if __name__=="__main__":
    main()

你可能感兴趣的:(点云,linux)