python-pcl安装教程

        在开始前,先说明一下,pcl的库安装不简单,不仅需要pip安装,还需要安装C++的pcl库,所以整个流程会比较漫长。鉴于官方参考网站的python-pcl太麻烦,我会用pclpy来代替python-pcl

官方参考网站:https://github.com/strawlab/python-pcl

 

1. 安装C++的pcl库PCL All-In-One Installer

http://pointclouds.org/downloads/windows.html

2. 安装Windows Gtk+ Download 

http://www.tarnyko.net/dl/gtk.htm

3. 安装pclpy,这里用pclpy代替python-pcl,避免新手要编译的麻烦

pip install pclpy

 

        最后展示一下使用例程,这里包含三个方法:

1. 将pcd转成bin(kitti格式)

2. pcd两种保存格式(binary/ascii),将binary转成ascii格式

3. 显示pcd格式

import pclpy
from pclpy import pcl
import numpy as np


def show_pcd(pcd_src_path):
    ''' 显示pcd内容'''
    pcl_file = pcl.PointCloud.PointXYZI()
    pcl.io.loadPCDFile(pcd_src_path, pcl_file)
    viewer = pcl.visualization.PCLVisualizer('PCD viewer')
    viewer.addPointCloud(pcl_file)
    while(not viewer.wasStopped()):
        viewer.spinOnce(100)


if __name__ == '__main__':
    pcd_src_path = r'C:\others\python\label_for_3d_desktop\label_for_3d_now\data\cross_walk.pcd'
    pcd_ascii_dst_path = r'C:\others\python\label_for_3d_desktop\label_for_3d_now\data\cross_walk-ascii.pcd'
    bin_dst_path = r'C:\others\python\label_for_3d_desktop\label_for_3d_now\data\cross_walk.bin'
    show_pcd(pcd_src_path)

 

你可能感兴趣的:(python)