PCL 环境搭建与例程

来源:互联网 发布:手机上网数据自动关闭 编辑:程序博客网 时间:2024/05/21 18:36

PCL 环境搭建与例程

vs版本:vs 2010
windows版本:windows 7 64位
pcl版本:1.6

PCL(Point Cloud Library)是在吸收了前人点云相关研究基础上建立起来的大型跨平台开源C++编程库,它实现了大量点云相关的通用算法和高效数据结构,涉及到点云获取、滤波、分割、配准、检索、特征提取、识别、追踪、曲面重建、可视化等。支持多种操作系统平台,可在Windows、Linux、Android、Mac OS X、部分嵌入式实时系统上运行。如果说OpenCV是2D信息获取与处理的结晶,那么PCL就在3D信息获取与处理上具有同等地位,PCL是BSD授权方式,可以免费进行商业和学术应用。 —-摘自PCL中文官网

1. 版本选择和安装

下载页面 http://pointclouds.org/downloads/

我选择的是Window版本的,windows可以选择all-in-one版本或者选择自己下载依赖,总共有boost,Eigen等库,个人建议使用all-in-one版本,这样方便管理和引入,独立下载依赖的话安装完后比较分散。我的系统是64位的windows7,但下载64位的版本安装后,无法链接lib,应该就是头文件和lib的版本不对,重新下载了32位的版本才调试成功。在已经设置了lib后,如果还无法链接,考虑头文件是否与lib匹配,可能同一个头文件在vs的引入目录中有多个目录存在,或者是lib 的版本不对,刚开始在这里浪费了很多时间。
安装过程可以选择是否加入环境变量,默认其它的依赖会安装到pcl所在的目录。

All in One
分模块

2. 配置使用

包含目录
vs 2010 的包含目录,D:\Program Files是我的安装目录,因为之前安装了64位的,所以装在了这个文件夹。

D:\Program Files\PCL 1.6.0\include\pcl-1.6D:\Program Files\PCL 1.6.0\3rdParty\VTK\include\vtk-5.8D:\Program Files\PCL 1.6.0\3rdParty\Qhull\includeD:\Program Files\PCL 1.6.0\3rdParty\OpenNID:\Program Files\PCL 1.6.0\3rdParty\FLANN\includeD:\Program Files\PCL 1.6.0\3rdParty\Eigen\includeD:\Program Files\PCL 1.6.0\3rdParty\Boost\include

库目录

D:\Program Files\PCL 1.6.0\3rdParty\VTK\lib\vtk-5.8D:\Program Files\PCL 1.6.0\3rdParty\FLANN\libD:\Program Files\PCL 1.6.0\3rdParty\Qhull\libD:\Program Files\PCL 1.6.0\3rdParty\Boost\libD:\Program Files\PCL 1.6.0\lib

lib

opengl32.libpcl_kdtree_debug.libpcl_io_debug.libpcl_search_debug.libpcl_segmentation_debug.libpcl_apps_debug.libpcl_features_debug.libpcl_filters_debug.libpcl_visualization_debug.libpcl_common_debug.libflann_cpp_s-gd.liblibboost_system-vc100-mt-gd-1_47.liblibboost_filesystem-vc100-mt-gd-1_47.liblibboost_thread-vc100-mt-gd-1_47.liblibboost_date_time-vc100-mt-gd-1_47.liblibboost_iostreams-vc100-mt-gd-1_47.libvtkalglib-gd.libvtkCharts-gd.libvtkCommon-gd.libvtkDICOMParser-gd.libvtkexoIIc-gd.libvtkexpat-gd.libvtkFiltering-gd.libvtkfreetype-gd.libvtkftgl-gd.libvtkGenericFiltering-gd.libvtkGeovis-gd.libvtkGraphics-gd.libvtkhdf5-gd.libvtkHybrid-gd.libvtkImaging-gd.libvtkInfovis-gd.libvtkIO-gd.libvtkjpeg-gd.libvtklibxml2-gd.libvtkmetaio-gd.libvtkNetCDF-gd.libvtkNetCDF_cxx-gd.libvtkpng-gd.libvtkproj4-gd.libvtkRendering-gd.libvtksqlite-gd.libvtksys-gd.libvtktiff-gd.libvtkverdict-gd.libvtkViews-gd.libvtkVolumeRendering-gd.libvtkWidgets-gd.libvtkzlib-gd.lib

3. 例程

在官网的教程里有很多例程,在本地目录D:\Program Files\PCL 1.6.0\share\doc\pcl-1.6\tutorials\sources 也包含了很多例程,这里是一个显示PCD文件的例程

#include <pcl/visualization/cloud_viewer.h>#include <iostream>#include <pcl/io/io.h>#include <pcl/io/pcd_io.h>int user_data;void viewerOneOff (pcl::visualization::PCLVisualizer& viewer){    viewer.setBackgroundColor (1.0, 0.5, 1.0);    pcl::PointXYZ o;    o.x = 1.0;    o.y = 0;    o.z = 0;    viewer.addSphere (o, 0.25, "sphere", 0);    std::cout << "i only run once" << std::endl;}void viewerPsycho (pcl::visualization::PCLVisualizer& viewer){    static unsigned count = 0;    std::stringstream ss;    ss << "Once per viewer loop: " << count++;    viewer.removeShape ("text", 0);    viewer.addText (ss.str(), 200, 300, "text", 0);    //FIXME: possible race condition here:    user_data++;}int main (){    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);    pcl::io::loadPCDFile ("cat.pcd", *cloud);    pcl::visualization::CloudViewer viewer("Cloud Viewer");    //blocks until the cloud is actually rendered    viewer.showCloud(cloud);    //use the following functions to get access to the underlying more advanced/powerful    //PCLVisualizer    //This will only get called once    viewer.runOnVisualizationThreadOnce (viewerOneOff);    //This will get called once per visualization iteration    viewer.runOnVisualizationThread (viewerPsycho);    while (!viewer.wasStopped ())    {    //you can also do cool processing here    //FIXME: Note that this is running in a separate thread from viewerPsycho    //and you should guard against race conditions yourself...    user_data++;    }    return 0;}

可视化的使用快捷键

快捷键 作用 r 重置视角 g 出现坐标抽 alt+ -/+ 放大缩小

4. 一些参考地址

PCL的github:https://github.com/PointCloudLibrary
PCL官网:http://pointclouds.org/
PCL中文官网:http://www.pclcn.org/
PCL的一些PCD数据:https://github.com/PointCloudLibrary/data
PCL教程地址:http://pointclouds.org/documentation/tutorials/#keypoints-tutorial
PCL图书:点云库PCL学习教程

PCL官网更新缓慢,github更新较快,建议多关注PCL的github。

阅读全文
0 0
原创粉丝点击