pypcd 安装
python2 安装
pip install pypcd
python3安装
git clone https://github.com/dimatura/pypcd
cd pypcd
git fetch origin pull/9/head:python3
git checkout python3
python3 setup.py install
点云 3D 数据 的读取、保存
import numpy as np
from pypcd import pypcd
file_path = "./point_cloud/test.pcd"
pcd = pypcd.PointCloud.from_path(file_path)
point_cloud = np.zeros((pcd.points, len(pcd.fields)), dtype=np.float32)
for i, field in enumerate(pcd.fields):
point_cloud[:, i] = np.transpose(pcd.pc_data[field])
point_cloud = point_cloud[:, 0:4]
store_path = "./point_cloud/test_save.pcd"
meta_data = {}
meta_data ['version'] = '0.7'
meta_data ['fields'] = ['x', 'y', 'z', 'intensity']
meta_data ['size'] = [4, 4, 4, 4]
meta_data ['type'] = ['F', 'F', 'F', 'F']
meta_data ['count'] = [1, 1, 1, 1]
meta_data ['width'] = 129366
meta_data ['height'] = 1
meta_data ['viewpoint'] = [0, 0, 1, 0, 0, 0]
meta_data ['points'] = 129366
meta_data ['data'] = 'ascii'
pcd_save = pypcd.PointCloud(meta_data, point_cloud)
pcd.save_pcd(store_path , compression='ascii')