1、下载PCL1.8.0:PCL-1.8.0-AllInOne-msvc2015-win64.exe,可从官网下载。
2、安装PCL,按提示安装即可。
3、配置环境变量。
;C:\Program Files\PCL 1.8.0\bin;C:\Program Files\PCL 1.8.0\3rdParty\FLANN\bin;C:\Program Files\PCL 1.8.0\3rdParty\Qhull\bin;C:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Tools;C:\Program Files\PCL 1.8.0\3rdParty\VTK\bin
4、重启电脑
5、打开VS2015,新建win32控制台程序。
6、打开项目属性,配置“调试”-“环境”,内容:PATH=$(PCL_ROOT)\bin;$(PCL_ROOT)\3rdParty\FLANN\bin;$(PCL_ROOT)\3rdParty\VTK\bin;$(PCL_ROOT)\3rdParty\Qhull\bin;$(PCL_ROOT)\3rdParty\OpenNI2\Tools;$(PATH)
7、配置“VC++目录”-“包含目录”,内容:E:\Program Files\PCL 1.8.0\include\pcl-1.8
E:\Program Files\PCL 1.8.0\3rdParty\Boost\include
E:\Program Files\PCL 1.8.0\3rdParty\Eigen\eigen3
E:\Program Files\PCL 1.8.0\3rdParty\FLANN\include
E:\Program Files\PCL 1.8.0\3rdParty\Qhull\include
E:\Program Files\PCL 1.8.0\3rdParty\VTK\include\vtk-7.0
E:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Include
E:\Program Files\PCL 1.8.0\3rdParty\Boost\include\boost-1_61
E:\Program Files\PCL 1.8.0\3rdParty\Boost\include
E:\Program Files\PCL 1.8.0\3rdParty\Eigen\eigen3
E:\Program Files\PCL 1.8.0\3rdParty\FLANN\include
E:\Program Files\PCL 1.8.0\3rdParty\Qhull\include
E:\Program Files\PCL 1.8.0\3rdParty\VTK\include\vtk-7.0
E:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Include
E:\Program Files\PCL 1.8.0\3rdParty\Boost\include\boost-1_61
8、配置“VC++目录”-“库目录”,内容:E:\Program Files\PCL 1.8.0\3rdParty\Boost\include\boost-1_61
E:\Program Files\PCL 1.8.0\3rdParty\FLANN\lib
E:\Program Files\PCL 1.8.0\3rdParty\Boost\lib
E:\Program Files\PCL 1.8.0\3rdParty\VTK\lib
E:\Program Files\PCL 1.8.0\3rdParty\Qhull\lib
E:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Lib
E:\Program Files\PCL 1.8.0\lib
E:\Program Files\PCL 1.8.0\3rdParty\FLANN\lib
E:\Program Files\PCL 1.8.0\3rdParty\Boost\lib
E:\Program Files\PCL 1.8.0\3rdParty\VTK\lib
E:\Program Files\PCL 1.8.0\3rdParty\Qhull\lib
E:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Lib
E:\Program Files\PCL 1.8.0\lib
9、配置“C/C++"-"常规”-“附加包含目录”,内容:e:\Program Files\PCL 1.8.0\3rdParty\Boost\include\boost-1_61
10、配置
“C/C++"-“预处理器”-“预处理器定义”,内容:_SCL_SECURE_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS
11、配置“链接器”-“输入”,内容: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
flann_cpp_s-gd.lib
flann_s-gd.lib
flann-gd.lib
libboost_atomic-vc140-mt-gd-1_61.lib
libboost_chrono-vc140-mt-gd-1_61.lib
libboost_container-vc140-mt-gd-1_61.lib
libboost_context-vc140-mt-gd-1_61.lib
libboost_coroutine-vc140-mt-gd-1_61.lib
libboost_date_time-vc140-mt-gd-1_61.lib
libboost_exception-vc140-mt-gd-1_61.lib
libboost_filesystem-vc140-mt-gd-1_61.lib
libboost_graph-vc140-mt-gd-1_61.lib
libboost_iostreams-vc140-mt-gd-1_61.lib
libboost_locale-vc140-mt-gd-1_61.lib
libboost_log-vc140-mt-gd-1_61.lib
libboost_log_setup-vc140-mt-gd-1_61.lib
libboost_math_c99-vc140-mt-gd-1_61.lib
libboost_math_c99f-vc140-mt-gd-1_61.lib
libboost_math_c99l-vc140-mt-gd-1_61.lib
libboost_math_tr1-vc140-mt-gd-1_61.lib
libboost_math_tr1f-vc140-mt-gd-1_61.lib
libboost_math_tr1l-vc140-mt-gd-1_61.lib
libboost_mpi-vc140-mt-gd-1_61.lib
libboost_prg_exec_monitor-vc140-mt-gd-1_61.lib
libboost_program_options-vc140-mt-gd-1_61.lib
libboost_random-vc140-mt-gd-1_61.lib
libboost_regex-vc140-mt-gd-1_61.lib
libboost_serialization-vc140-mt-gd-1_61.lib
libboost_signals-vc140-mt-gd-1_61.lib
libboost_system-vc140-mt-gd-1_61.lib
libboost_test_exec_monitor-vc140-mt-gd-1_61.lib
libboost_thread-vc140-mt-gd-1_61.lib
libboost_timer-vc140-mt-gd-1_61.lib
libboost_unit_test_framework-vc140-mt-gd-1_61.lib
libboost_wave-vc140-mt-gd-1_61.lib
libboost_wserialization-vc140-mt-gd-1_61.lib
qhull_d.lib
qhull_p_d.lib
qhull_r_d.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_r_d.lib
vtkalglib-7.0-gd.lib
vtkChartsCore-7.0-gd.lib
vtkCommonColor-7.0-gd.lib
vtkCommonComputationalGeometry-7.0-gd.lib
vtkCommonCore-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
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
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
vtkRenderingVolume-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
OpenNI2.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
flann_cpp_s-gd.lib
flann_s-gd.lib
flann-gd.lib
libboost_atomic-vc140-mt-gd-1_61.lib
libboost_chrono-vc140-mt-gd-1_61.lib
libboost_container-vc140-mt-gd-1_61.lib
libboost_context-vc140-mt-gd-1_61.lib
libboost_coroutine-vc140-mt-gd-1_61.lib
libboost_date_time-vc140-mt-gd-1_61.lib
libboost_exception-vc140-mt-gd-1_61.lib
libboost_filesystem-vc140-mt-gd-1_61.lib
libboost_graph-vc140-mt-gd-1_61.lib
libboost_iostreams-vc140-mt-gd-1_61.lib
libboost_locale-vc140-mt-gd-1_61.lib
libboost_log-vc140-mt-gd-1_61.lib
libboost_log_setup-vc140-mt-gd-1_61.lib
libboost_math_c99-vc140-mt-gd-1_61.lib
libboost_math_c99f-vc140-mt-gd-1_61.lib
libboost_math_c99l-vc140-mt-gd-1_61.lib
libboost_math_tr1-vc140-mt-gd-1_61.lib
libboost_math_tr1f-vc140-mt-gd-1_61.lib
libboost_math_tr1l-vc140-mt-gd-1_61.lib
libboost_mpi-vc140-mt-gd-1_61.lib
libboost_prg_exec_monitor-vc140-mt-gd-1_61.lib
libboost_program_options-vc140-mt-gd-1_61.lib
libboost_random-vc140-mt-gd-1_61.lib
libboost_regex-vc140-mt-gd-1_61.lib
libboost_serialization-vc140-mt-gd-1_61.lib
libboost_signals-vc140-mt-gd-1_61.lib
libboost_system-vc140-mt-gd-1_61.lib
libboost_test_exec_monitor-vc140-mt-gd-1_61.lib
libboost_thread-vc140-mt-gd-1_61.lib
libboost_timer-vc140-mt-gd-1_61.lib
libboost_unit_test_framework-vc140-mt-gd-1_61.lib
libboost_wave-vc140-mt-gd-1_61.lib
libboost_wserialization-vc140-mt-gd-1_61.lib
qhull_d.lib
qhull_p_d.lib
qhull_r_d.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_r_d.lib
vtkalglib-7.0-gd.lib
vtkChartsCore-7.0-gd.lib
vtkCommonColor-7.0-gd.lib
vtkCommonComputationalGeometry-7.0-gd.lib
vtkCommonCore-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
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
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
vtkRenderingVolume-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
OpenNI2.lib
12、测试代码。
void viewerOneOff(pcl::visualization::PCLVisualizer& viewer) {
viewer.setBackgroundColor(1.0, 0.5, 1.0); //设置背景颜色
}
#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;
#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>);
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;
}
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对象
pcl::visualization::CloudViewer viewer("Cloud Viewer"); //创建viewer对象
viewer.showCloud(cloud);
viewer.runOnVisualizationThreadOnce(viewerOneOff);
system("pause");
return 0;
}
viewer.runOnVisualizationThreadOnce(viewerOneOff);
system("pause");
return 0;
}