標籤:iic 輸入 function segment debug com read use 依賴庫
PCL簡介
PCL(Point Cloud Library)是在吸收了前人點雲相關研究基礎上建立起來的大型跨平台開源C++編程庫,它實現了大量點雲相關的通用演算法和高效資料結構,涉及到點雲擷取、濾波、分割、配准、檢索、特徵提取、識別、追蹤、曲面重建、可視化等。支援多種作業系統平台,可在Windows、Linux、Android、Mac OS X、部分嵌入式即時系統上運行。如果說OpenCV是2D資訊擷取與處理的結晶,那麼PCL就在3D資訊擷取與處理上具有同等地位,PCL是BSD授權方式,可以免費進行商業和學術應用。
最近剛接觸PCL,發現用到PCL的人還是比較少,可供學習的資料也不多,所以,我想從頭開始學習,並記錄下學習的過程。如果有興趣一起學習的同學可以加我QQ761551935,我們一起交流學習。
學習資源:
PCL 1.8.0 比較全的安裝包及安裝步驟:http://unanancyowen.com/en/pcl18/
PCL 相關資料匯總:https://github.com/neilgu00365/Survey-for-SfMMission
PCL 中國點雲庫:http://www.pclcn.org/
環境:windows+vs2010
如果你沒有vs2010我給你分享一個安裝包連結:http://pan.baidu.com/s/1pL3I0dH 密碼:a53o
一、下載
我用的是PCL 1.6.0 All-In-One Installer,Windows MSVC 2010 (32bit),所以,下面是以這個版本為主。其實,只要下載PCL-1.6.0-AllInOne-msvc2010-win32.exe、OpenNI 1.5.4 (patched)和Sensor 5.1.0 (patched)三個檔案就可以了,PCL-1.6.0-AllInOne-msvc2010-win32.exe內部已經包含了全部的依賴庫,安裝的過程中,OpenNI會安裝不上,所以要單獨下載,其它的依賴庫都可以不用下載。
- 官方:http://pointclouds.org/downloads/windows.html
二、安裝
分別安裝
1、PCL-1.6.0-AllInOne-msvc2010-win32.exe
2、OpenNI-Win32-1.5.4-Dev.msi
3、Sensor-Win-OpenSource32-5.1.0.msi
注意:你要編譯的是Win32和Win64的版本要區別開,PCL和依賴庫都統一用同一個版本的,否則啟動並執行時候會報錯。
三、配置
1、配置包含路徑
將PCL安裝路徑下的3rdParty目錄下的include添加進去,另外OpenNI單獨安裝的路徑也添加進去,還有PCL安裝路徑下的Include\pcl-1.6也添加進去。
2、配置庫路徑
將PCL安裝路徑下的3rdParty目錄下的lib添加進去,另外OpenNI單獨安裝的路徑也添加進去,還有PCL安裝路徑下的lib也添加進去。
3、配置輸入庫檔案
添加下列檔案名稱
opengl32.libpcl_apps_debug.libpcl_common_debug.libpcl_features_debug.libpcl_filters_debug.libpcl_io_debug.libpcl_io_ply_debug.libpcl_kdtree_debug.libpcl_keypoints_debug.libpcl_octree_debug.libpcl_registration_debug.libpcl_sample_consensus_debug.libpcl_search_debug.libpcl_segmentation_debug.libpcl_surface_debug.libpcl_tracking_debug.libpcl_visualization_debug.libflann_cpp_s-gd.libboost_chrono-vc100-mt-gd-1_49.libboost_date_time-vc100-mt-gd-1_47.libboost_date_time-vc100-mt-gd-1_49.libboost_filesystem-vc100-mt-gd-1_47.libboost_filesystem-vc100-mt-gd-1_49.libboost_graph-vc100-mt-gd-1_49.libboost_graph_parallel-vc100-mt-gd-1_49.libboost_iostreams-vc100-mt-gd-1_47.libboost_iostreams-vc100-mt-gd-1_49.libboost_locale-vc100-mt-gd-1_49.libboost_math_c99-vc100-mt-gd-1_49.libboost_math_c99f-vc100-mt-gd-1_49.libboost_math_tr1-vc100-mt-gd-1_49.libboost_math_tr1f-vc100-mt-gd-1_49.libboost_mpi-vc100-mt-gd-1_49.libboost_prg_exec_monitor-vc100-mt-gd-1_49.libboost_program_options-vc100-mt-gd-1_49.libboost_random-vc100-mt-gd-1_49.libboost_regex-vc100-mt-gd-1_49.libboost_serialization-vc100-mt-gd-1_49.libboost_signals-vc100-mt-gd-1_49.libboost_system-vc100-mt-gd-1_47.libboost_system-vc100-mt-gd-1_49.libboost_thread-vc100-mt-gd-1_47.libboost_thread-vc100-mt-gd-1_49.libboost_timer-vc100-mt-gd-1_49.libboost_unit_test_framework-vc100-mt-gd-1_49.libboost_wave-vc100-mt-gd-1_49.libboost_wserialization-vc100-mt-gd-1_49.liblibboost_chrono-vc100-mt-gd-1_49.liblibboost_date_time-vc100-mt-gd-1_47.liblibboost_date_time-vc100-mt-gd-1_49.liblibboost_filesystem-vc100-mt-gd-1_47.liblibboost_filesystem-vc100-mt-gd-1_49.liblibboost_graph_parallel-vc100-mt-gd-1_49.liblibboost_iostreams-vc100-mt-gd-1_47.liblibboost_iostreams-vc100-mt-gd-1_49.liblibboost_locale-vc100-mt-gd-1_49.liblibboost_math_c99-vc100-mt-gd-1_49.liblibboost_math_c99f-vc100-mt-gd-1_49.liblibboost_math_tr1-vc100-mt-gd-1_49.liblibboost_math_tr1f-vc100-mt-gd-1_49.liblibboost_mpi-vc100-mt-gd-1_49.liblibboost_prg_exec_monitor-vc100-mt-gd-1_49.liblibboost_program_options-vc100-mt-gd-1_49.liblibboost_random-vc100-mt-gd-1_49.liblibboost_regex-vc100-mt-gd-1_49.liblibboost_serialization-vc100-mt-gd-1_49.liblibboost_signals-vc100-mt-gd-1_49.liblibboost_system-vc100-mt-gd-1_47.liblibboost_system-vc100-mt-gd-1_49.liblibboost_test_exec_monitor-vc100-mt-gd-1_49.liblibboost_thread-vc100-mt-gd-1_47.liblibboost_thread-vc100-mt-gd-1_49.liblibboost_timer-vc100-mt-gd-1_49.liblibboost_unit_test_framework-vc100-mt-gd-1_49.liblibboost_wave-vc100-mt-gd-1_49.liblibboost_wserialization-vc100-mt-gd-1_49.libvtkalglib-gd.libvtkCharts-gd.libvtkCommon-gd.libvtkDICOMParser-gd.libvtkexoIIc-gd.libvtkexpat-gd.libvtkFiltering-gd.libvtkfreetype-gd.libvtkftgl-gd.libvtkGenericFiltering-gd.libvtkGeovis-gd.libvtkGraphics-gd.libvtkhdf5-gd.libvtkHybrid-gd.libvtkImaging-gd.libvtkInfovis-gd.libvtkIO-gd.libvtkjpeg-gd.libvtklibxml2-gd.libvtkmetaio-gd.libvtkNetCDF-gd.libvtkNetCDF_cxx-gd.libvtkpng-gd.libvtkproj4-gd.libvtkRendering-gd.libvtksqlite-gd.libvtksys-gd.libvtktiff-gd.libvtkverdict-gd.libvtkViews-gd.libvtkVolumeRendering-gd.libvtkWidgets-gd.libvtkzlib-gd.lib
檔案有點多,這裡可以有個比較快的方法:這裡以vtk為例,
開啟CMD->進入PCL的安裝目錄->進入3rdParty\VTK\lib\vtk-5.8目錄->輸入命令:dir /b *gd.lib -> list.txt
命令的意思是找出gd.lib結尾的檔案並儲存到list.txt文檔裡面。然後目前的目錄就會產生list.txt
四、Demo
常式:
#include <pcl/visualization/cloud_viewer.h>#include <iostream>#include <pcl/io/io.h>#include <pcl/io/pcd_io.h>int user_data;void viewerOneOff (pcl::visualization::PCLVisualizer& viewer){ viewer.setBackgroundColor (0, 0, 0); pcl::PointXYZ o; o.x = 1.0; o.y = 0; o.z = 0; viewer.addSphere (o, 0.25, "sphere", 0); std::cout << "i only run once" << std::endl;}void viewerPsycho (pcl::visualization::PCLVisualizer& viewer){ static unsigned count = 0; std::stringstream ss; ss << "Once per viewer loop: " << count++; viewer.removeShape ("text", 0); viewer.addText (ss.str(), 200, 300, "text", 0); //FIXME: possible race condition here: user_data++;}int main (){ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>); pcl::io::loadPCDFile ("my_point_cloud.pcd", *cloud); pcl::visualization::CloudViewer viewer("Cloud Viewer"); //blocks until the cloud is actually rendered viewer.showCloud(cloud); //use the following functions to get access to the underlying more advanced/powerful //PCLVisualizer //This will only get called once viewer.runOnVisualizationThreadOnce (viewerOneOff); //This will get called once per visualization iteration viewer.runOnVisualizationThread (viewerPsycho); while (!viewer.wasStopped ()) { //you can also do cool processing here //FIXME: Note that this is running in a separate thread from viewerPsycho //and you should guard against race conditions yourself... user_data++; } return 0;}
以上是用realsense的SR300擷取到我案頭的點雲。
my_point_cloud.pcd 檔案 連結:http://pan.baidu.com/s/1gfD2lF1 密碼:cexi
五、總結分享
1、pcd讀取有點慢,據說pcd資料以有序點雲的方式儲存會好一點,但是沒我試了沒看出來能快多少,這個有待研究。
2、SR300直接擷取的深度映像和RGB映像座標上有偏差,這個考慮下怎麼做對齊。
3、如果工程配置上SR300的SDK和opencv,我們就不需要在另一個工程先儲存pcd檔案再讀取,中間就可以省了很多步驟。
4、PCL的學習資料還是很少,目前聽說比較好也就只有《點雲庫PCL學習教程》,我也買了一本,慢慢學吧。
PCL 1.60 +windows+vs2010 安裝與配置