前言
本篇文章主要介绍一下PCL库的配置过程,适合PCL入门。
一配置环境
1.win10 X64 2.Visual Studio 2013
二 准备工作
下文我们均以64位操作系统为例。首先,下载需要的文件,我将相关文件包已经上传到了网盘,下载链接为:https://pan.baidu.com/s/1WUUBR_MLA12ZBdu2ayYghQ 密码:z7fw
三 安装
1.双击安装包中的「PCL-1.8.0-AllInOne-msvc2013-win64.exe」程序,安装的时候注意选上「Add PCL to the system PATH for all users」,如图所示,这样安装程序会自动在系统环境变量中添加「PCL_ROOT」项。
以下具体内容都以我的安装路径为例:
2.安装的过程中会弹出OpenNI的安装程序,将OpenNI的安装路径设置为PCL_ROOT下的3rdPartyOpenNI2文件夹,例:
3.安装程序执行完成后,将pdb文件压缩包解压(即:PCL-1.8.0-AllInOne-msvc2013-win64-pdb.rar),pdb文件拷贝到PCL ROOT下的bin文件夹中,例如:
D:ProGrammeFilesPCL1.8.0PCL 1.8.0
四 环境变量
上面说过了安装程序会自动添加PCL_ROOT到系统环境变量中,此外还要手动添加QHull、FLANN、VTK、OpenNI2的bin目录到PATH中,例: 注意:如果安装程序没有自动添加PCL_ROOT则需要手动添加(如下图所示)
五 项目配置
1.在VS2013中新建项目。注意:VS2013中Configuration Manager(配置管理器)默认Active solution plantform(活动平台)是win32,如果安装的是x64的PCL需要将其改成x64,否则编译时候会出现奇怪的问题。
2.Solution Explorer(解决方案管理器)中右键项目->Properties(属性)
Configuration Properties(配置管理器)->C/C ->Preprocessor(预处理器)->Preprocessor Definitions(预处理定义)中添加如下两项:
_SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS
3.Property Manager(属性管理器)中。
Property Manager与Solution Explorer在同一个tab布局中,如果没找到的话,可通过如下方式寻找属性管理器:菜单栏的VIEW(视图)->Other Windows(其他窗口)->Property Manager(属性管理器)。
接下来开始配置属性表,此处以debug模式下配置为例: (1)新建一个工程「PCL_Test」,如上图,将项目设置成64位。 (2)切换属性管理器,在Debug|64位下添加新项目属性表,取名为「PCL_Debug.props」。 左侧VC 目录,包含目录设置如图:
左侧VC 目录,库目录设置如图:
左侧链接器-输入,附加依赖项:
附加依赖项中,配置内容如下(debug版本下):
pcl_common_debug.lib pcl_features_debug.lib pcl_filters_debug.lib pcl_io_debug.lib pcl_io_ply_debug.lib pcl_kdtree_debug.lib pcl_keypoints_debug.lib pcl_ml_debug.lib pcl_octree_debug.lib pcl_outofcore_debug.lib pcl_people_debug.lib pcl_recognition_debug.lib pcl_registration_debug.lib pcl_sample_consensus_debug.lib pcl_search_debug.lib pcl_segmentation_debug.lib pcl_stereo_debug.lib pcl_surface_debug.lib pcl_tracking_debug.lib pcl_visualization_debug.lib libboost_atomic-vc120-mt-gd-1_59.lib libboost_chrono-vc120-mt-gd-1_59.lib libboost_container-vc120-mt-gd-1_59.lib libboost_context-vc120-mt-gd-1_59.lib libboost_coroutine-vc120-mt-gd-1_59.lib libboost_date_time-vc120-mt-gd-1_59.lib libboost_exception-vc120-mt-gd-1_59.lib libboost_filesystem-vc120-mt-gd-1_59.lib libboost_graph-vc120-mt-gd-1_59.lib libboost_iostreams-vc120-mt-gd-1_59.lib libboost_locale-vc120-mt-gd-1_59.lib libboost_log-vc120-mt-gd-1_59.lib libboost_log_setup-vc120-mt-gd-1_59.lib libboost_math_c99-vc120-mt-gd-1_59.lib libboost_math_c99f-vc120-mt-gd-1_59.lib libboost_math_c99l-vc120-mt-gd-1_59.lib libboost_math_tr1-vc120-mt-gd-1_59.lib libboost_math_tr1f-vc120-mt-gd-1_59.lib libboost_math_tr1l-vc120-mt-gd-1_59.lib libboost_mpi-vc120-mt-gd-1_59.lib libboost_prg_exec_monitor-vc120-mt-gd-1_59.lib libboost_program_options-vc120-mt-gd-1_59.lib libboost_random-vc120-mt-gd-1_59.lib libboost_regex-vc120-mt-gd-1_59.lib libboost_serialization-vc120-mt-gd-1_59.lib libboost_signals-vc120-mt-gd-1_59.lib libboost_system-vc120-mt-gd-1_59.lib libboost_test_exec_monitor-vc120-mt-gd-1_59.lib libboost_thread-vc120-mt-gd-1_59.lib libboost_timer-vc120-mt-gd-1_59.lib libboost_unit_test_framework-vc120-mt-gd-1_59.lib libboost_wave-vc120-mt-gd-1_59.lib libboost_wserialization-vc120-mt-gd-1_59.lib vtkalglib-7.0-gd.lib vtkChartsCore-7.0-gd.lib vtkCommonCore-7.0-gd.lib vtkCommonColor-7.0-gd.lib vtkCommonComputationalGeometry-7.0-gd.lib vtkCommonDataModel-7.0-gd.lib vtkCommonExecutionModel-7.0-gd.lib vtkCommonMath-7.0-gd.lib vtkCommonMisc-7.0-gd.lib vtkCommonSystem-7.0-gd.lib vtkCommonTransforms-7.0-gd.lib vtkDICOMParser-7.0-gd.lib vtkDomainsChemistry-7.0-gd.lib vtkexoIIc-7.0-gd.lib vtkexpat-7.0-gd.lib vtkFiltersAMR-7.0-gd.lib vtkFiltersCore-7.0-gd.lib vtkFiltersExtraction-7.0-gd.lib vtkFiltersFlowPaths-7.0-gd.lib vtkFiltersGeneral-7.0-gd.lib vtkFiltersGeneric-7.0-gd.lib vtkFiltersGeometry-7.0-gd.lib vtkFiltersHybrid-7.0-gd.lib vtkFiltersHyperTree-7.0-gd.lib vtkFiltersImaging-7.0-gd.lib vtkFiltersModeling-7.0-gd.lib vtkFiltersParallel-7.0-gd.lib vtkFiltersParallelImaging-7.0-gd.lib vtkFiltersProgrammable-7.0-gd.lib vtkFiltersSelection-7.0-gd.lib vtkFiltersSMP-7.0-gd.lib vtkFiltersSources-7.0-gd.lib vtkFiltersStatistics-7.0-gd.lib vtkFiltersTexture-7.0-gd.lib vtkFiltersVerdict-7.0-gd.lib vtkfreetype-7.0-gd.lib vtkGeovisCore-7.0-gd.lib vtkhdf5-7.0-gd.lib vtkhdf5_hl-7.0-gd.lib vtkImagingColor-7.0-gd.lib vtkImagingCore-7.0-gd.lib vtkImagingFourier-7.0-gd.lib vtkImagingGeneral-7.0-gd.lib vtkImagingHybrid-7.0-gd.lib vtkImagingMath-7.0-gd.lib vtkImagingMorphological-7.0-gd.lib vtkImagingSources-7.0-gd.lib vtkImagingStatistics-7.0-gd.lib vtkImagingStencil-7.0-gd.lib vtkInfovisCore-7.0-gd.lib vtkInfovisLayout-7.0-gd.lib vtkInteractionImage-7.0-gd.lib vtkInteractionStyle-7.0-gd.lib vtkInteractionWidgets-7.0-gd.lib vtkIOAMR-7.0-gd.lib vtkIOCore-7.0-gd.lib vtkIOEnSight-7.0-gd.lib vtkIOExodus-7.0-gd.lib vtkIOExport-7.0-gd.lib vtkIOGeometry-7.0-gd.lib vtkIOImage-7.0-gd.lib vtkIOImport-7.0-gd.lib vtkIOInfovis-7.0-gd.lib vtkIOLegacy-7.0-gd.lib vtkIOLSDyna-7.0-gd.lib vtkIOMINC-7.0-gd.lib vtkIOMovie-7.0-gd.lib vtkIONetCDF-7.0-gd.lib vtkIOParallel-7.0-gd.lib vtkIOParallelXML-7.0-gd.lib vtkIOPLY-7.0-gd.lib vtkIOSQL-7.0-gd.lib vtkIOVideo-7.0-gd.lib vtkIOXML-7.0-gd.lib vtkIOXMLParser-7.0-gd.lib vtkjpeg-7.0-gd.lib vtkjsoncpp-7.0-gd.lib vtklibxml2-7.0-gd.lib vtkmetaio-7.0-gd.lib vtkNetCDF-7.0-gd.lib vtkNetCDF_cxx-7.0-gd.lib vtkoggtheora-7.0-gd.lib vtkParallelCore-7.0-gd.lib vtkpng-7.0-gd.lib vtkproj4-7.0-gd.lib vtkRenderingAnnotation-7.0-gd.lib vtkRenderingContext2D-7.0-gd.lib vtkRenderingContextOpenGL2-7.0-gd.lib vtkRenderingCore-7.0-gd.lib vtkRenderingFreeType-7.0-gd.lib vtkRenderingImage-7.0-gd.lib vtkRenderingLabel-7.0-gd.lib vtkRenderingLOD-7.0-gd.lib vtkRenderingOpenGL2-7.0-gd.lib vtkRenderingVolume-7.0-gd.lib vtkRenderingVolumeOpenGL2-7.0-gd.lib vtksqlite-7.0-gd.lib vtksys-7.0-gd.lib vtktiff-7.0-gd.lib vtkverdict-7.0-gd.lib vtkViewsContext2D-7.0-gd.lib vtkViewsCore-7.0-gd.lib vtkViewsInfovis-7.0-gd.lib vtkzlib-7.0-gd.lib vtkGUISupportQt-7.0-gd.lib vtkRenderingQt-7.0-gd.lib vtkViewsQt-7.0-gd.lib flann_cpp_s-gd.lib qhullstatic-gd.lib OpenNI2.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib comctl32.lib wsock32.lib glu32.lib opengl32.lib ws2_32.lib Psapi.lib
release版本下的附加依赖项,配置如下:
pcl_common_release.lib pcl_features_release.lib pcl_filters_release.lib pcl_io_ply_release.lib pcl_io_release.lib pcl_kdtree_release.lib pcl_keypoints_release.lib pcl_ml_release.lib pcl_octree_release.lib pcl_outofcore_release.lib pcl_people_release.lib pcl_recognition_release.lib pcl_registration_release.lib pcl_sample_consensus_release.lib pcl_search_release.lib pcl_segmentation_release.lib pcl_stereo_release.lib pcl_surface_release.lib pcl_tracking_release.lib pcl_visualization_release.lib libboost_atomic-vc120-mt-1_59.lib libboost_chrono-vc120-mt-1_59.lib libboost_container-vc120-mt-1_59.lib libboost_context-vc120-mt-1_59.lib libboost_coroutine-vc120-mt-1_59.lib libboost_date_time-vc120-mt-1_59.lib libboost_exception-vc120-mt-1_59.lib libboost_filesystem-vc120-mt-1_59.lib libboost_graph-vc120-mt-1_59.lib libboost_iostreams-vc120-mt-1_59.lib libboost_locale-vc120-mt-1_59.lib libboost_log-vc120-mt-1_59.lib libboost_log_setup-vc120-mt-1_59.lib libboost_math_c99-vc120-mt-1_59.lib libboost_math_c99f-vc120-mt-1_59.lib libboost_math_c99l-vc120-mt-1_59.lib libboost_math_tr1-vc120-mt-1_59.lib libboost_math_tr1f-vc120-mt-1_59.lib libboost_math_tr1l-vc120-mt-1_59.lib libboost_mpi-vc120-mt-1_59.lib libboost_prg_exec_monitor-vc120-mt-1_59.lib libboost_program_options-vc120-mt-1_59.lib libboost_random-vc120-mt-1_59.lib libboost_regex-vc120-mt-1_59.lib libboost_serialization-vc120-mt-1_59.lib libboost_signals-vc120-mt-1_59.lib libboost_system-vc120-mt-1_59.lib libboost_test_exec_monitor-vc120-mt-1_59.lib libboost_thread-vc120-mt-1_59.lib libboost_timer-vc120-mt-1_59.lib libboost_unit_test_framework-vc120-mt-1_59.lib libboost_wave-vc120-mt-1_59.lib libboost_wserialization-vc120-mt-1_59.lib flann_cpp_s.lib flann_s.lib qhull.lib qhullcpp.lib qhullstatic.lib qhullstatic_r.lib qhull_p.lib qhull_r.lib vtkalglib-7.0.lib vtkChartsCore-7.0.lib vtkCommonColor-7.0.lib vtkCommonComputationalGeometry-7.0.lib vtkCommonCore-7.0.lib vtkCommonDataModel-7.0.lib vtkCommonExecutionModel-7.0.lib vtkCommonMath-7.0.lib vtkCommonMisc-7.0.lib vtkCommonSystem-7.0.lib vtkCommonTransforms-7.0.lib vtkDICOMParser-7.0.lib vtkDomainsChemistry-7.0.lib vtkDomainsChemistryOpenGL2-7.0.lib vtkexoIIc-7.0.lib vtkexpat-7.0.lib vtkFiltersAMR-7.0.lib vtkFiltersCore-7.0.lib vtkFiltersExtraction-7.0.lib vtkFiltersFlowPaths-7.0.lib vtkFiltersGeneral-7.0.lib vtkFiltersGeneric-7.0.lib vtkFiltersGeometry-7.0.lib vtkFiltersHybrid-7.0.lib vtkFiltersHyperTree-7.0.lib vtkFiltersImaging-7.0.lib vtkFiltersModeling-7.0.lib vtkFiltersParallel-7.0.lib vtkFiltersParallelImaging-7.0.lib vtkFiltersProgrammable-7.0.lib vtkFiltersSelection-7.0.lib vtkFiltersSMP-7.0.lib vtkFiltersSources-7.0.lib vtkFiltersStatistics-7.0.lib vtkFiltersTexture-7.0.lib vtkFiltersVerdict-7.0.lib vtkfreetype-7.0.lib vtkGeovisCore-7.0.lib vtkglew-7.0.lib vtkGUISupportQt-7.0.lib vtkGUISupportQtSQL-7.0.lib vtkhdf5-7.0.lib vtkhdf5_hl-7.0.lib vtkImagingColor-7.0.lib vtkImagingCore-7.0.lib vtkImagingFourier-7.0.lib vtkImagingGeneral-7.0.lib vtkImagingHybrid-7.0.lib vtkImagingMath-7.0.lib vtkImagingMorphological-7.0.lib vtkImagingSources-7.0.lib vtkImagingStatistics-7.0.lib vtkImagingStencil-7.0.lib vtkInfovisCore-7.0.lib vtkInfovisLayout-7.0.lib vtkInteractionImage-7.0.lib vtkInteractionStyle-7.0.lib vtkInteractionWidgets-7.0.lib vtkIOAMR-7.0.lib vtkIOCore-7.0.lib vtkIOEnSight-7.0.lib vtkIOExodus-7.0.lib vtkIOExport-7.0.lib vtkIOGeometry-7.0.lib vtkIOImage-7.0.lib vtkIOImport-7.0.lib vtkIOInfovis-7.0.lib vtkIOLegacy-7.0.lib vtkIOLSDyna-7.0.lib vtkIOMINC-7.0.lib vtkIOMovie-7.0.lib vtkIONetCDF-7.0.lib vtkIOParallel-7.0.lib vtkIOParallelXML-7.0.lib vtkIOPLY-7.0.lib vtkIOSQL-7.0.lib vtkIOVideo-7.0.lib vtkIOXML-7.0.lib vtkIOXMLParser-7.0.lib vtkjpeg-7.0.lib vtkjsoncpp-7.0.lib vtklibxml2-7.0.lib vtkmetaio-7.0.lib vtkNetCDF-7.0.lib vtkNetCDF_cxx-7.0.lib vtkoggtheora-7.0.lib vtkParallelCore-7.0.lib vtkpng-7.0.lib vtkproj4-7.0.lib vtkRenderingAnnotation-7.0.lib vtkRenderingContext2D-7.0.lib vtkRenderingContextOpenGL2-7.0.lib vtkRenderingCore-7.0.lib vtkRenderingFreeType-7.0.lib vtkRenderingImage-7.0.lib vtkRenderingLabel-7.0.lib vtkRenderingLOD-7.0.lib vtkRenderingOpenGL2-7.0.lib vtkRenderingQt-7.0.lib vtkRenderingVolume-7.0.lib vtkRenderingVolumeOpenGL2-7.0.lib vtksqlite-7.0.lib vtksys-7.0.lib vtktiff-7.0.lib vtkverdict-7.0.lib vtkViewsContext2D-7.0.lib vtkViewsCore-7.0.lib vtkViewsInfovis-7.0.lib vtkViewsQt-7.0.lib vtkzlib-7.0.lib
上面的包含目录,库目录按你自己的来,附加依赖项有些库版本不同,不同的建议去搜其他的。
六 工程测试
新建一个cpp文件,输入下列代码:
代码语言:javascript复制#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::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("my_point_cloud.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;
}
运行之后,如果出现下图:
上下滚动下鼠标滚轮,便可以得到下图:
说明工程属性表配置成功。
七 结语
博文中所述过程,对于PCL各个版本和windows各个系统版本都有效。下载正确的PCL和VS版本,是配置的前提。从PCL All in one 安装包名称可以了解PCL版本及需要的VS版本或系统位数。
八 跋
快速提问通道。