一、配置环境
1.win7 64位
2.Visual Studio 2015
二 、准备工作
安装包准备:
移步:https://www.cnblogs.com/weiyouqing/p/8046387.html
三、 安装
1.双击安装包中的「PCL-1.8.0-AllInOne-msvc2013-win64.exe」程序,安装的时候注意选上Add PCL to the system PATH for all users,如图所示,这样安装程序会自动在系统环境变量中添加PCL_ROOT项。
3.安装程序执行完成后,将pdb文件压缩包解压(即:PCL-1.8.0-AllInOne-msvc2013-win64-pdb.rar),pdb文件拷贝到PCL安装目录下的bin文件夹中。
四 、添加环境变量
1.点击win7的控制面板->系统->高级系统设置->在系统属性的“高级选项”卡下点击“环境变量”;
2.在系统子菜单里面找到“Path”,如图:
3.点击编辑,添加如下:
;C:Program FilesPCL 1.8.0in;C:Program FilesPCL 1.8.03rdPartyFLANNin;C:Program FilesPCL 1.8.03rdPartyQhullin;C:Program FilesPCL 1.8.03rdPartyOpenNI2Tools;C:Program FilesPCL 1.8.03rdPartyVTKin
注意这里的“ ; ”分号;
注意,第一项在“一键安装”时就已经添加。
链接:https://zhuanlan.zhihu.com/p/36590026
五 、重启电脑
六、VS2015工程配置步骤
1.打开VS2015,创建新的win32控制台工程,建好后将平台改成X64;
2.点击项目菜单的属性,如图:
3.在弹出的对话框中,
① 点击“包含目录”下拉箭头->编辑,添加文件路径:
完成后点击确定;
②点击“库目录”下拉箭头->编辑,添加文件路径:
完成后点击确定;
4.点击连接器->输入->附加依赖项:
点击下拉箭头->编辑,添加下列文件:
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-vc140-mt-1_61.lib
libboost_chrono-vc140-mt-1_61.lib
libboost_container-vc140-mt-1_61.lib
libboost_context-vc140-mt-1_61.lib
libboost_coroutine-vc140-mt-1_61.lib
libboost_date_time-vc140-mt-1_61.lib
libboost_exception-vc140-mt-1_61.lib
libboost_filesystem-vc140-mt-1_61.lib
libboost_graph-vc140-mt-1_61.lib
libboost_iostreams-vc140-mt-1_61.lib
libboost_locale-vc140-mt-1_61.lib
libboost_log-vc140-mt-1_61.lib
libboost_log_setup-vc140-mt-1_61.lib
libboost_math_c99-vc140-mt-1_61.lib
libboost_math_c99f-vc140-mt-1_61.lib
libboost_math_c99l-vc140-mt-1_61.lib
libboost_math_tr1-vc140-mt-1_61.lib
libboost_math_tr1f-vc140-mt-1_61.lib
libboost_math_tr1l-vc140-mt-1_61.lib
libboost_mpi-vc140-mt-1_61.lib
libboost_prg_exec_monitor-vc140-mt-1_61.lib
libboost_program_options-vc140-mt-1_61.lib
libboost_random-vc140-mt-1_61.lib
libboost_regex-vc140-mt-1_61.lib
libboost_serialization-vc140-mt-1_61.lib
libboost_signals-vc140-mt-1_61.lib
libboost_system-vc140-mt-1_61.lib
libboost_test_exec_monitor-vc140-mt-1_61.lib
libboost_thread-vc140-mt-1_61.lib
libboost_timer-vc140-mt-1_61.lib
libboost_unit_test_framework-vc140-mt-1_61.lib
libboost_wave-vc140-mt-1_61.lib
libboost_wserialization-vc140-mt-1_61.lib
flann.lib
flann_s.lib
flann-gd.lib
flann_cpp_s.lib
flann_cpp_s-gd.lib
flann_s-gd.lib
qhull.lib
qhull_d.lib
qhullcpp_d.lib
qhullstatic.lib
qhullstatic_d.lib
qhullstatic_r.lib
qhullstatic_r_d.lib
qhull_p.lib
qhull_p_d.lib
qhull_r.lib
qhull_r_d.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
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
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
vtkRenderingContextOpenGL-7.0.lib
vtkRenderingCore-7.0.lib
vtkRenderingFreeType-7.0.lib
vtkRenderingImage-7.0.lib
vtkRenderingLabel-7.0.lib
vtkRenderingLOD-7.0.lib
vtkRenderingOpenGL-7.0.lib
vtkRenderingVolume-7.0.lib
vtkRenderingVolumeOpenGL-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
vtkzlib-7.0.lib
完成后点击确定;
注意:上面为在release下运行的文件,如果想在debug下运行,则将其中的release改成debug;
5.点击配置属性下的调试,右边有个环境项,把值设置为PATH=$(PCL_ROOT)bin;$(PCL_ROOT)3rdPartyFLANNbin;$(PCL_ROOT)3rdPartyVTKbin;$(PCL_ROOT)Qhullbin;$(PCL_ROOT)3rdPartyOpenNI2Tools;$(PATH)
6.点击配置属性下的CC++,点击它的子项预处理器,右边有个预处理器定义,添加上_SCL_SECURE_NO_WARNINGS 和 _CRT_SECURE_NO_WARNINGS。
7.点击配置属性下的CC++,常规
在附加包含目录中添加:C:Program FilesPCL 1.8.03rdPartyBoostincludeoost-1_61
8.在属性管理器里点击项目,展开子项。
Property Manager与Solution Explorer在同一个tab布局中,如果没找到的话,可通过如下方式寻找属性管理器:菜单栏的VIEW(视图)->Other Windows(其他窗口)->Property Manager(属性管理器)。
如果安装的是32位,点击选中开头为Debug的子项里右键,点击添加现有属性表,然后找到你下载的文件夹里的PCLDebug.props,添加上。点击选中开头为Release的子项里右键,点击添加现有属性表,然后找到你下载的文件夹里的PCLRelease.props,添加上。
如果安装的是64位,点击选中开头为Debug的子项里右键,点击添加现有属性表,然后找到你下载的文件夹里的PCLDebug.props,添加上。点击选中开头为Release的子项里右键,点击添加现有属性表,然后找到你下载的文件夹里的PCLRelease.props,添加上。
注意在这里,64位的会有2个开头为Debug的子项,都要添加上PCLDebug.props,并且2个开头为Release的子项,也要添加上PCLRelease.props。
关于PCLRelease.props文件和PCLDebug.props文件在网盘的链接里面有;(https://www.cnblogs.com/weiyouqing/p/8046387.html)
9.
注意:如果出现以下这种问题:
解决方案:
从上图中的箭头中,将问题中提示的.lib文件删除即可;
五、程序实际测试
将rabbit.pcd(在网盘中,链接: https://pan.baidu.com/s/1BhoOHQHFPwMorfEJnDeiXg 提取码: k8t5)放到与工程中的主.cpp同一位置的文件夹下(工程文件夹)
程序代码:
#include<pcl/visualization/cloud_viewer.h> #include<iostream>//标准C++库中的输入输出类相关头文件。 #include<pcl/io/io.h> #include<pcl/io/pcd_io.h>//pcd 读写类相关的头文件。 #include<pcl/io/ply_io.h> #include<pcl/point_types.h> //PCL中支持的点类型头文件。 int user_data; using std::cout; void viewerOneOff(pcl::visualization::PCLVisualizer& viewer) { viewer.setBackgroundColor(1.0, 0.5, 1.0); //设置背景颜色 } int main() { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); char strfilepath[256] = "rabbit.pcd"; if (-1 == pcl::io::loadPCDFile(strfilepath, *cloud)) { cout << "error input!" << endl; return -1; } cout << cloud->points.size() << endl; pcl::visualization::CloudViewer viewer("Cloud Viewer"); //创建viewer对象 viewer.showCloud(cloud); viewer.runOnVisualizationThreadOnce(viewerOneOff); system("pause"); return 0; }
效果图:
来源:https://www.cnblogs.com/weiyouqing/p/8046387.html