參考網友的資料整理爲更詳細的解決方案ios
1、下載相關文件sql
1.下載PCL-1.8.0-AllInOne-msvc2015-win64.exe、屬性表和PDB和測試pcd文件rabbit.pcd,其中,屬性表能夠不下載。json
百度雲連接:https://pan.baidu.com/s/1dFwDIQt 密碼:mcvgdom
2、Windows7下安裝步驟:ide
1.點擊PCL-1.8.0-AllInOne-msvc2015-win64.exe一鍵安裝,能夠默認也能夠本身選擇安裝路徑,如本文所選擇的路徑爲默認安裝路徑C:\Program Files;測試
2.在安裝過程當中,OpenNI2在安裝時會彈出界面,選擇目錄C:\Program Files\PCL 1.8.0\3rdParty\OpenNI2;atom
3.等待一段時間,則安裝完成。spa
注意事項:在安裝點擊「我接收(I)」以後彈出來的對話框中必定要選擇第二項AddPCL to the system PATH for all users:(如圖)debug
3、系統配置步驟3d
1.點擊win7的控制面板->系統->高級系統設置->在系統屬性的「高級選項」卡下點擊「環境變量」;
2.在系統子菜單裏面找到「Path」,如圖:
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.重啓電腦
4、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 Files\PCL 1.8.0\3rdParty\Boost\include\boost-1_61
8.在屬性管理器裏點擊項目,展開子項。
若是安裝的是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文件在網盤的連接裏面有;
9.
注意:若是出現如下這種問題:
解決方案:
從上圖中的箭頭中,將問題中提示的.lib文件刪除便可;
5、程序實際測試
將rabbit.pcd(在網盤中)放到與工程中的主.cpp同一位置的文件夾下(工程文件夾)
程序代碼:
1 #include<pcl/visualization/cloud_viewer.h> 2 #include<iostream>//標準C++庫中的輸入輸出類相關頭文件。 3 #include<pcl/io/io.h> 4 #include<pcl/io/pcd_io.h>//pcd 讀寫類相關的頭文件。 5 #include<pcl/io/ply_io.h> 6 #include<pcl/point_types.h> //PCL中支持的點類型頭文件。 7 int user_data; 8 using std::cout; 9 10 11 void viewerOneOff(pcl::visualization::PCLVisualizer& viewer) { 12 viewer.setBackgroundColor(1.0, 0.5, 1.0); //設置背景顏色 13 } 14 15 int main() { 16 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); 17 18 char strfilepath[256] = "rabbit.pcd"; 19 if (-1 == pcl::io::loadPCDFile(strfilepath, *cloud)) { 20 cout << "error input!" << endl; 21 return -1; 22 } 23 24 cout << cloud->points.size() << endl; 25 pcl::visualization::CloudViewer viewer("Cloud Viewer"); //建立viewer對象 26 27 viewer.showCloud(cloud); 28 viewer.runOnVisualizationThreadOnce(viewerOneOff); 29 system("pause"); 30 return 0; 31 }
效果圖: