1. 安装PCL
【在安装过程中,如果遇到了 path too long installer unable to modify path报错的问题,点击确定后,查看环境变量,确实没有配置pcl和opennl的环境变量,这个时候也不要慌,pcl已经安装就位了,只是环境变量没有自动配置好,后续手动配置即可。】
(1)下载以下两个文件:http://unanancyowen.com/en/pcl181/
(2)运行安装文件,进行安装:
(3)安装openin的时候选择PCL安装路径下的3rdParty文件夹下面;
(4)PDB文件(解压后放在安装目录的bin下面);
2. 环境变量配置
如果安装时选择自动生成就无需修改:
并且手动添加下图所示变量:
3. VS配置
(1)首先创建一个新的项目,debug x64;
(2)然后打开配置管理器,添加新项目属性表,可命名为PCL(方便以后重复的使用,重复使用时选择添加现有属性表);
(3) 双击PCL属性表进行修改属性操作:
- 首先修改VC++目录下的包含目录,具体修改内容如下图:
包含目录修改如下:
$(PCL_ROOT)\include\pcl-1.8
$(PCL_ROOT)\3rdParty\Boost\include\boost-1_64
$(PCL_ROOT)\3rdParty\Qhull\include
$(PCL_ROOT)\3rdParty\FLANN\include\flann
$(PCL_ROOT)\3rdParty\Eigen\eigen3
$(PCL_ROOT)\3rdParty\VTK\include\vtk-8.0
$(PCL_ROOT)\3rdParty\OpenNI2\Include
- 然后修改VC++目录下的库目录,具体修改内容如下图:
库目录修改如下:
$(PCL_ROOT)\lib
$(PCL_ROOT)\3rdParty\Boost\lib
$(PCL_ROOT)\3rdParty\Qhull\lib
$(PCL_ROOT)\3rdParty\FLANN\lib
$(PCL_ROOT)\3rdParty\VTK\lib
$(PCL_ROOT)\3rdParty\OpenNI2\Lib
- 最后修改链接器——>输入——>附加依赖性:
依赖项添加如下:
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-vc140-mt-gd-1_64.lib
libboost_bzip2-vc140-mt-gd-1_64.lib
libboost_chrono-vc140-mt-gd-1_64.lib
libboost_container-vc140-mt-gd-1_64.lib
libboost_context-vc140-mt-gd-1_64.lib
libboost_coroutine-vc140-mt-gd-1_64.lib
libboost_date_time-vc140-mt-gd-1_64.lib
libboost_exception-vc140-mt-gd-1_64.lib
libboost_fiber-vc140-mt-gd-1_64.lib
libboost_filesystem-vc140-mt-gd-1_64.lib
libboost_graph_parallel-vc140-mt-gd-1_64.lib
libboost_graph-vc140-mt-gd-1_64.lib
libboost_iostreams-vc140-mt-gd-1_64.lib
libboost_locale-vc140-mt-gd-1_64.lib
libboost_log-vc140-mt-gd-1_64.lib
libboost_log_setup-vc140-mt-gd-1_64.lib
libboost_math_c99-vc140-mt-gd-1_64.lib
libboost_math_c99f-vc140-mt-gd-1_64.lib
libboost_math_c99l-vc140-mt-gd-1_64.lib
libboost_math_tr1-vc140-mt-gd-1_64.lib
libboost_math_tr1f-vc140-mt-gd-1_64.lib
libboost_math_tr1l-vc140-mt-gd-1_64.lib
libboost_mpi-vc140-mt-gd-1_64.lib
libboost_numpy3-vc140-mt-gd-1_64.lib
libboost_numpy-vc140-mt-gd-1_64.lib
libboost_prg_exec_monitor-vc140-mt-gd-1_64.lib
libboost_program_options-vc140-mt-gd-1_64.lib
libboost_python3-vc140-mt-gd-1_64.lib
libboost_python-vc140-mt-gd-1_64.lib
libboost_random-vc140-mt-gd-1_64.lib
libboost_regex-vc140-mt-gd-1_64.lib
libboost_serialization-vc140-mt-gd-1_64.lib
libboost_signals-vc140-mt-gd-1_64.lib
libboost_system-vc140-mt-gd-1_64.lib
libboost_test_exec_monitor-vc140-mt-gd-1_64.lib
libboost_thread-vc140-mt-gd-1_64.lib
libboost_timer-vc140-mt-gd-1_64.lib
libboost_type_erasure-vc140-mt-gd-1_64.lib
libboost_unit_test_framework-vc140-mt-gd-1_64.lib
libboost_wave-vc140-mt-gd-1_64.lib
libboost_wserialization-vc140-mt-gd-1_64.lib
libboost_zlib-vc140-mt-gd-1_64.lib
vtkzlib-8.0-gd.lib
vtkViewsContext2D-8.0-gd.lib
vtkhdf5_hl-8.0-gd.lib
vtkFiltersProgrammable-8.0-gd.lib
vtkIOMovie-8.0-gd.lib
vtkexpat-8.0-gd.lib
vtkRenderingLOD-8.0-gd.lib
vtkIOPLY-8.0-gd.lib
vtkpng-8.0-gd.lib
vtkIOVideo-8.0-gd.lib
vtkRenderingImage-8.0-gd.lib
vtkFiltersVerdict-8.0-gd.lib
vtkjpeg-8.0-gd.lib
vtkInteractionImage-8.0-gd.lib
vtkverdict-8.0-gd.lib
vtkoggtheora-8.0-gd.lib
vtkImagingStatistics-8.0-gd.lib
vtkCommonSystem-8.0-gd.lib
vtkFiltersParallelImaging-8.0-gd.lib
vtkFiltersTexture-8.0-gd.lib
vtkCommonMisc-8.0-gd.lib
vtkCommonMath-8.0-gd.lib
vtkFiltersSelection-8.0-gd.lib
vtkImagingFourier-8.0-gd.lib
vtkIOXMLParser-8.0-gd.lib
vtkproj4-8.0-gd.lib
vtkalglib-8.0-gd.lib
vtktiff-8.0-gd.lib
vtksqlite-8.0-gd.lib
vtkImagingSources-8.0-gd.lib
vtkCommonTransforms-8.0-gd.lib
vtkImagingMath-8.0-gd.lib
vtkFiltersGeneric-8.0-gd.lib
vtkexoIIc-8.0-gd.lib
vtkfreetype-8.0-gd.lib
vtkImagingColor-8.0-gd.lib
vtknetcdf_c++-gd.lib
vtkNetCDF-8.0-gd.lib
vtkFiltersImaging-8.0-gd.lib
vtkFiltersHyperTree-8.0-gd.lib
vtkImagingMorphological-8.0-gd.lib
vtkImagingStencil-8.0-gd.lib
vtkRenderingFreeType-8.0-gd.lib
vtkCommonColor-8.0-gd.lib
vtkjsoncpp-8.0-gd.lib
vtkRenderingContext2D-8.0-gd.lib
vtkFiltersAMR-8.0-gd.lib
vtkRenderingContextOpenGL-8.0-gd.lib
vtkIOParallelXML-8.0-gd.lib
vtkViewsCore-8.0-gd.lib
vtkImagingHybrid-8.0-gd.lib
vtkIOExport-8.0-gd.lib
vtkRenderingVolumeOpenGL-8.0-gd.lib
vtkIOImport-8.0-gd.lib
vtkDomainsChemistry-8.0-gd.lib
vtkInteractionStyle-8.0-gd.lib
vtkCommonComputationalGeometry-8.0-gd.lib
vtkDICOMParser-8.0-gd.lib
vtklibxml2-8.0-gd.lib
vtkIOMINC-8.0-gd.lib
vtkIOSQL-8.0-gd.lib
vtkFiltersModeling-8.0-gd.lib
vtkParallelCore-8.0-gd.lib
vtkIOAMR-8.0-gd.lib
vtkGeovisCore-8.0-gd.lib
vtksys-8.0-gd.lib
vtkIOEnSight-8.0-gd.lib
vtkImagingGeneral-8.0-gd.lib
vtkFiltersFlowPaths-8.0-gd.lib
vtkIOLSDyna-8.0-gd.lib
vtkFiltersSMP-8.0-gd.lib
vtkIOParallel-8.0-gd.lib
vtkFiltersGeometry-8.0-gd.lib
vtkInfovisLayout-8.0-gd.lib
vtkIOCore-8.0-gd.lib
vtkFiltersSources-8.0-gd.lib
vtkIOLegacy-8.0-gd.lib
vtkFiltersHybrid-8.0-gd.lib
vtkIONetCDF-8.0-gd.lib
vtkFiltersExtraction-8.0-gd.lib
vtkFiltersParallel-8.0-gd.lib
vtkRenderingLabel-8.0-gd.lib
vtkIOInfovis-8.0-gd.lib
vtkRenderingAnnotation-8.0-gd.lib
vtkImagingCore-8.0-gd.lib
vtkCommonExecutionModel-8.0-gd.lib
vtkhdf5-8.0-gd.lib
vtkViewsInfovis-8.0-gd.lib
vtkIOGeometry-8.0-gd.lib
vtkmetaio-8.0-gd.lib
vtkIOImage-8.0-gd.lib
vtkIOXML-8.0-gd.lib
vtkIOExodus-8.0-gd.lib
vtkRenderingVolume-8.0-gd.lib
vtkChartsCore-8.0-gd.lib
vtkFiltersStatistics-8.0-gd.lib
vtkInfovisCore-8.0-gd.lib
vtkRenderingCore-8.0-gd.lib
vtkInteractionWidgets-8.0-gd.lib
vtkRenderingOpenGL-8.0-gd.lib
vtkFiltersGeneral-8.0-gd.lib
vtkFiltersCore-8.0-gd.lib
vtkCommonDataModel-8.0-gd.lib
vtkCommonCore-8.0-gd.lib
flann_cpp_s-gd.lib
qhullstatic_d.lib
OpenNI2.lib
- 在C/C++ 预处理器-》预处理器定义添加
_SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS
至此,配置完毕;
4. 测试:显示小白兔
rabbit.pcd在百度云盘 https://pan.baidu.com/s/1Gsnsb4AllcJxjdsYbGw-Cw
// TestPCL.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#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;
}