1. 程式人生 > >【PCL點雲庫】Win10+VS2015+PCL1.8.1配置

【PCL點雲庫】Win10+VS2015+PCL1.8.1配置

最近需要用到點雲庫,所以需要配置PCL,看了網上寫的一些教程,寫的都還可以,但是都有一些問題,所以本人在參考其他博主教程的基礎上加以改進儘量將配置過程講的仔細一點,本人也是從小白過來的,所以理解萬歲,當然也要感謝下列博主的經驗,站在巨人的肩膀上令我少走很多彎路,廢話不多說。

1. VS2015的安裝

這個不用教了吧,相信來搜尋教程的都應該裝了的,本人是裝了VS2015社群版。

2. PCL 1.8.1安裝

這裡說明一下,本人是windows10,64位系統,在VS2015環境下配置,所以請32位或者其他VS版本下載對應版本。

2.1 PLC1.8.1安裝過程

雙擊PCL-1.8.1-AllInOne-msvc2015-win64.exe,如圖所示自動新增系統路徑,點選下一步

可以設定自己的安裝路徑,但是這裡有兩個問題需要注意:

a)不要用中文安裝路徑,搞科研應該都懂的!

b)路徑中不要有任何空格,如下圖系統會自動給你生成有空格的路徑,你需要修改去掉空格就行,這樣做的目的是如果以後用到了QT,QT是不能識別空格的路徑的,所以建議這裡刪掉空格,當然不用QT可以忽略。本人路徑:G:\PCL1.8.1\PCL1.8.1。路徑中第一個PCL1.8.1資料夾使我自己建的,第二個PCL1.8.1資料夾是軟體生成的,需要刪掉空格。

下一步再將第三方安裝包都勾選上 ,點選安裝,安裝過程中會彈出視窗提示安裝OpenNI,將OpenNI的安裝路徑更改為自己選定的安裝PCL的第三方庫(3rdparty資料夾)的路徑下即:G:\PCL1.8.1\PCL1.8.1\3rdparty\OpenNI2,然後同意安裝PrimerSense 

等待一會兒就安裝完成了,安裝過後可能會有視窗警告提示你路徑太長,新增不了之類的錯誤提示,不用管不影響。

2.1 PLC1.8.1配置變數

之前勾選了Add PCL to system PATH for all users,安裝好後,系統變數裡會自動出現如下圖所示的4個變數:

然後雙擊系統變數中的Path,進入編輯環境變數

新建以下6個環境變數,然後重啟電腦使變數生效。

最後解壓之前下載的PCL-1.8.1-pdb-msvc2017-win64.zip,將裡面的pdb檔案全部複製到PCL安裝路徑下bin資料夾中

本人路徑:G:\PCL1.8.1\PCL1.8.1\bin

3. VS2015環境下配置PCL 1.8.1

3.1 Release下配置

開啟VS2015,新建C++,Win32控制檯應用程式,點選完成。

點選屬性管理器,在Release|x64右擊,新增新專案屬性表,取名PCLRelease64,如下圖:

雙擊PCLRelease64,彈出屬性頁,左側選中VC++目錄。

右側包含目錄新增如下路徑(根據自己的路徑一一對應起來)

右側庫目錄新增如下路徑(根據自己的路徑一一對應起來)

左側點選連結器,再點輸入,右側找到附加依賴項,新增如下依賴項(直接複製貼上)

shell32.lib vtknetcdf_c++.lib 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_64.lib libboost_bzip2-vc140-mt-1_64.lib libboost_chrono-vc140-mt-1_64.lib libboost_container-vc140-mt-1_64.lib libboost_context-vc140-mt-1_64.lib libboost_coroutine-vc140-mt-1_64.lib libboost_date_time-vc140-mt-1_64.lib libboost_exception-vc140-mt-1_64.lib libboost_fiber-vc140-mt-1_64.lib libboost_filesystem-vc140-mt-1_64.lib libboost_graph-vc140-mt-1_64.lib libboost_graph_parallel-vc140-mt-1_64.lib libboost_iostreams-vc140-mt-1_64.lib libboost_locale-vc140-mt-1_64.lib libboost_log-vc140-mt-1_64.lib libboost_log_setup-vc140-mt-1_64.lib libboost_math_c99-vc140-mt-1_64.lib libboost_math_c99f-vc140-mt-1_64.lib libboost_math_c99l-vc140-mt-1_64.lib libboost_math_tr1-vc140-mt-1_64.lib libboost_math_tr1f-vc140-mt-1_64.lib libboost_math_tr1l-vc140-mt-1_64.lib libboost_mpi-vc140-mt-1_64.lib libboost_numpy3-vc140-mt-1_64.lib libboost_numpy-vc140-mt-1_64.lib libboost_prg_exec_monitor-vc140-mt-1_64.lib libboost_program_options-vc140-mt-1_64.lib libboost_python3-vc140-mt-1_64.lib libboost_python-vc140-mt-1_64.lib libboost_random-vc140-mt-1_64.lib libboost_regex-vc140-mt-1_64.lib libboost_serialization-vc140-mt-1_64.lib libboost_signals-vc140-mt-1_64.lib libboost_system-vc140-mt-1_64.lib libboost_test_exec_monitor-vc140-mt-1_64.lib libboost_thread-vc140-mt-1_64.lib libboost_timer-vc140-mt-1_64.lib libboost_type_erasure-vc140-mt-1_64.lib libboost_unit_test_framework-vc140-mt-1_64.lib libboost_wave-vc140-mt-1_64.lib libboost_wserialization-vc140-mt-1_64.lib libboost_zlib-vc140-mt-1_64.lib flann.lib flann_cpp.lib flann_cpp_s.lib flann_s.lib qhull_d.lib qhullcpp_d.lib qhullstatic_d.lib qhullstatic_r_d.lib qhull_p_d.lib qhull_r_d.lib vtkalglib-8.0.lib vtkChartsCore-8.0.lib vtkCommonColor-8.0.lib vtkCommonComputationalGeometry-8.0.lib vtkCommonCore-8.0.lib vtkCommonDataModel-8.0.lib vtkCommonExecutionModel-8.0.lib vtkCommonMath-8.0.lib vtkCommonMisc-8.0.lib vtkCommonSystem-8.0.lib vtkCommonTransforms-8.0.lib vtkDICOMParser-8.0.lib vtkDomainsChemistry-8.0.lib vtkexoIIc-8.0.lib vtkexpat-8.0.lib vtkFiltersAMR-8.0.lib vtkFiltersCore-8.0.lib vtkFiltersExtraction-8.0.lib vtkFiltersFlowPaths-8.0.lib vtkFiltersGeneral-8.0.lib vtkFiltersGeneric-8.0.lib vtkFiltersGeometry-8.0.lib vtkFiltersHybrid-8.0.lib vtkFiltersHyperTree-8.0.lib vtkFiltersImaging-8.0.lib vtkFiltersModeling-8.0.lib vtkFiltersParallel-8.0.lib vtkFiltersParallelImaging-8.0.lib vtkFiltersPoints-8.0.lib vtkFiltersProgrammable-8.0.lib vtkFiltersSelection-8.0.lib vtkFiltersSMP-8.0.lib vtkFiltersSources-8.0.lib vtkFiltersStatistics-8.0.lib vtkFiltersTexture-8.0.lib vtkFiltersTopology-8.0.lib vtkFiltersVerdict-8.0.lib vtkfreetype-8.0.lib vtkGeovisCore-8.0.lib vtkgl2ps-8.0.lib vtkhdf5-8.0.lib vtkhdf5_hl-8.0.lib vtkImagingColor-8.0.lib vtkImagingCore-8.0.lib vtkImagingFourier-8.0.lib vtkImagingGeneral-8.0.lib vtkImagingHybrid-8.0.lib vtkImagingMath-8.0.lib vtkImagingMorphological-8.0.lib vtkImagingSources-8.0.lib vtkImagingStatistics-8.0.lib vtkImagingStencil-8.0.lib vtkInfovisCore-8.0.lib vtkInfovisLayout-8.0.lib vtkInteractionImage-8.0.lib vtkInteractionStyle-8.0.lib vtkInteractionWidgets-8.0.lib vtkIOAMR-8.0.lib vtkIOCore-8.0.lib vtkIOEnSight-8.0.lib vtkIOExodus-8.0.lib vtkIOExport-8.0.lib vtkIOExportOpenGL-8.0.lib vtkIOGeometry-8.0.lib vtkIOImage-8.0.lib vtkIOImport-8.0.lib vtkIOInfovis-8.0.lib vtkIOLegacy-8.0.lib vtkIOLSDyna-8.0.lib vtkIOMINC-8.0.lib vtkIOMovie-8.0.lib vtkIONetCDF-8.0.lib vtkIOParallel-8.0.lib vtkIOParallelXML-8.0.lib vtkIOPLY-8.0.lib vtkIOSQL-8.0.lib vtkIOTecplotTable-8.0.lib vtkIOVideo-8.0.lib vtkIOXML-8.0.lib vtkIOXMLParser-8.0.lib vtkjpeg-8.0.lib vtkjsoncpp-8.0.lib vtklibharu-8.0.lib vtklibxml2-8.0.lib vtklz4-8.0.lib vtkmetaio-8.0.lib vtkNetCDF-8.0.lib vtkoggtheora-8.0.lib vtkParallelCore-8.0.lib vtkpng-8.0.lib vtkproj4-8.0.lib vtkRenderingAnnotation-8.0.lib vtkRenderingContext2D-8.0.lib vtkRenderingContextOpenGL-8.0.lib vtkRenderingCore-8.0.lib vtkRenderingFreeType-8.0.lib vtkRenderingGL2PS-8.0.lib vtkRenderingImage-8.0.lib vtkRenderingLabel-8.0.lib vtkRenderingLIC-8.0.lib vtkRenderingLOD-8.0.lib vtkRenderingOpenGL-8.0.lib vtkRenderingVolume-8.0.lib vtkRenderingVolumeOpenGL-8.0.lib vtksqlite-8.0.lib vtksys-8.0.lib vtktiff-8.0.lib vtkverdict-8.0.lib vtkViewsContext2D-8.0.lib vtkViewsCore-8.0.lib vtkViewsInfovis-8.0.lib vtkzlib-8.0.lib opengl32.lib

3.2 Debug下配置

Debug下配置與Release幾乎差不多,區別主要是

a)在Debug|x64下新增新專案屬性表,取名PCLDebug64,包含目錄跟庫目錄與Release下配置相同。 

b)附加依賴項有點區別,主要是有release命名的變成debug,新增如下依賴項(直接複製貼上)。

shell32.lib vtknetcdf_c++.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-1_64.lib libboost_bzip2-vc140-mt-1_64.lib libboost_chrono-vc140-mt-1_64.lib libboost_container-vc140-mt-1_64.lib libboost_context-vc140-mt-1_64.lib libboost_coroutine-vc140-mt-1_64.lib libboost_date_time-vc140-mt-1_64.lib libboost_exception-vc140-mt-1_64.lib libboost_fiber-vc140-mt-1_64.lib libboost_filesystem-vc140-mt-1_64.lib libboost_graph-vc140-mt-1_64.lib libboost_graph_parallel-vc140-mt-1_64.lib libboost_iostreams-vc140-mt-1_64.lib libboost_locale-vc140-mt-1_64.lib libboost_log-vc140-mt-1_64.lib libboost_log_setup-vc140-mt-1_64.lib libboost_math_c99-vc140-mt-1_64.lib libboost_math_c99f-vc140-mt-1_64.lib libboost_math_c99l-vc140-mt-1_64.lib libboost_math_tr1-vc140-mt-1_64.lib libboost_math_tr1f-vc140-mt-1_64.lib libboost_math_tr1l-vc140-mt-1_64.lib libboost_mpi-vc140-mt-1_64.lib libboost_numpy3-vc140-mt-1_64.lib libboost_numpy-vc140-mt-1_64.lib libboost_prg_exec_monitor-vc140-mt-1_64.lib libboost_program_options-vc140-mt-1_64.lib libboost_python3-vc140-mt-1_64.lib libboost_python-vc140-mt-1_64.lib libboost_random-vc140-mt-1_64.lib libboost_regex-vc140-mt-1_64.lib libboost_serialization-vc140-mt-1_64.lib libboost_signals-vc140-mt-1_64.lib libboost_system-vc140-mt-1_64.lib libboost_test_exec_monitor-vc140-mt-1_64.lib libboost_thread-vc140-mt-1_64.lib libboost_timer-vc140-mt-1_64.lib libboost_type_erasure-vc140-mt-1_64.lib libboost_unit_test_framework-vc140-mt-1_64.lib libboost_wave-vc140-mt-1_64.lib libboost_wserialization-vc140-mt-1_64.lib libboost_zlib-vc140-mt-1_64.lib flann.lib flann_cpp.lib flann_cpp_s.lib flann_s.lib qhull_d.lib qhullcpp_d.lib qhullstatic_d.lib qhullstatic_r_d.lib qhull_p_d.lib qhull_r_d.lib vtkalglib-8.0.lib vtkChartsCore-8.0.lib vtkCommonColor-8.0.lib vtkCommonComputationalGeometry-8.0.lib vtkCommonCore-8.0.lib vtkCommonDataModel-8.0.lib vtkCommonExecutionModel-8.0.lib vtkCommonMath-8.0.lib vtkCommonMisc-8.0.lib vtkCommonSystem-8.0.lib vtkCommonTransforms-8.0.lib vtkDICOMParser-8.0.lib vtkDomainsChemistry-8.0.lib vtkexoIIc-8.0.lib vtkexpat-8.0.lib vtkFiltersAMR-8.0.lib vtkFiltersCore-8.0.lib vtkFiltersExtraction-8.0.lib vtkFiltersFlowPaths-8.0.lib vtkFiltersGeneral-8.0.lib vtkFiltersGeneric-8.0.lib vtkFiltersGeometry-8.0.lib vtkFiltersHybrid-8.0.lib vtkFiltersHyperTree-8.0.lib vtkFiltersImaging-8.0.lib vtkFiltersModeling-8.0.lib vtkFiltersParallel-8.0.lib vtkFiltersParallelImaging-8.0.lib vtkFiltersPoints-8.0.lib vtkFiltersProgrammable-8.0.lib vtkFiltersSelection-8.0.lib vtkFiltersSMP-8.0.lib vtkFiltersSources-8.0.lib vtkFiltersStatistics-8.0.lib vtkFiltersTexture-8.0.lib vtkFiltersTopology-8.0.lib vtkFiltersVerdict-8.0.lib vtkfreetype-8.0.lib vtkGeovisCore-8.0.lib vtkgl2ps-8.0.lib vtkhdf5-8.0.lib vtkhdf5_hl-8.0.lib vtkImagingColor-8.0.lib vtkImagingCore-8.0.lib vtkImagingFourier-8.0.lib vtkImagingGeneral-8.0.lib vtkImagingHybrid-8.0.lib vtkImagingMath-8.0.lib vtkImagingMorphological-8.0.lib vtkImagingSources-8.0.lib vtkImagingStatistics-8.0.lib vtkImagingStencil-8.0.lib vtkInfovisCore-8.0.lib vtkInfovisLayout-8.0.lib vtkInteractionImage-8.0.lib vtkInteractionStyle-8.0.lib vtkInteractionWidgets-8.0.lib vtkIOAMR-8.0.lib vtkIOCore-8.0.lib vtkIOEnSight-8.0.lib vtkIOExodus-8.0.lib vtkIOExport-8.0.lib vtkIOExportOpenGL-8.0.lib vtkIOGeometry-8.0.lib vtkIOImage-8.0.lib vtkIOImport-8.0.lib vtkIOInfovis-8.0.lib vtkIOLegacy-8.0.lib vtkIOLSDyna-8.0.lib vtkIOMINC-8.0.lib vtkIOMovie-8.0.lib vtkIONetCDF-8.0.lib vtkIOParallel-8.0.lib vtkIOParallelXML-8.0.lib vtkIOPLY-8.0.lib vtkIOSQL-8.0.lib vtkIOTecplotTable-8.0.lib vtkIOVideo-8.0.lib vtkIOXML-8.0.lib vtkIOXMLParser-8.0.lib vtkjpeg-8.0.lib vtkjsoncpp-8.0.lib vtklibharu-8.0.lib vtklibxml2-8.0.lib vtklz4-8.0.lib vtkmetaio-8.0.lib vtkNetCDF-8.0.lib vtkoggtheora-8.0.lib vtkParallelCore-8.0.lib vtkpng-8.0.lib vtkproj4-8.0.lib vtkRenderingAnnotation-8.0.lib vtkRenderingContext2D-8.0.lib vtkRenderingContextOpenGL-8.0.lib vtkRenderingCore-8.0.lib vtkRenderingFreeType-8.0.lib vtkRenderingGL2PS-8.0.lib vtkRenderingImage-8.0.lib vtkRenderingLabel-8.0.lib vtkRenderingLIC-8.0.lib vtkRenderingLOD-8.0.lib vtkRenderingOpenGL-8.0.lib vtkRenderingVolume-8.0.lib vtkRenderingVolumeOpenGL-8.0.lib vtksqlite-8.0.lib vtksys-8.0.lib vtktiff-8.0.lib vtkverdict-8.0.lib vtkViewsContext2D-8.0.lib vtkViewsCore-8.0.lib vtkViewsInfovis-8.0.lib vtkzlib-8.0.lib opengl32.lib

OK!!!!到底為止配置就完成,特別要注意的是包含目錄和庫目錄裡新增的路徑一定要對,這裡的路徑錯了就會影響到程式裡面報錯無法開啟某某標頭檔案。

4. 程式測試

將bunny.pcd(百度雲盤連結如下)放到與程式main.cpp同一位置的資料夾下,如圖PCLTest(自命名)資料夾下。

程式碼如下:

#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;
}
 

程式執行結果:

到此為止就結束了,如果你看到上面這隻兔子,那麼恭喜你配置成功了,如果還是出現了問題,絕大多數還是路徑的問題。