資源簡介
完成的功能有:三維點云獲取,點云數據下采樣(為后續處理加速),平面檢測和獲取,3D顯示
在一個老外牛人的程序上改的,原版只支持點云獲取和顯示,不包括點云處理。另外,原版有個bug,會導致大量的CPU時間用來顯示無效的點云數據,已被我這版修正。
程序中有個宏開關CLOUD_DISPLAY,如果定義這個宏則有三維顯示,如果不定義這個宏則關閉三維顯示功能。關閉三維顯示的目的是為了加速三維點云數據的處理。
另外,使用本程序必要條件是要在你電腦上把Kinect SDK裝好,這個去官網下就是了。同時需要把PCL環境配好,推薦另外一個牛人的博客:http://www.zhangzscn.com/2016/03/02/pcl1-8-0%EF%BC%8Cvs2013%E9%85%8D%E7%BD%AE%E6%95%99%E7%A8%8B%E3%80%82/

代碼片段和文件信息
//?Disable?Error?C4996?that?occur?when?using?Boost.Signals2.
#ifdef?_DEBUG
#define?_SCL_SECURE_NO_WARNINGS
#endif
#include?“kinect2_grabber.h“
#include?
#include?
//?RANSAC
#include?
#include?
#include?
#include?
#include?
#include?
#define?CLOUD_DISPLAY?
typedef?pcl::PointXYZRGBA?PointType;
//typedef?pcl::PointXYZ?PointType;
int?produced_frame_count_last?=?0?produced_frame_count_current?=?0;
int?main(?int?argc?char*?argv[]?)
{
#ifdef?CLOUD_DISPLAY
????//?PCL?Visualizer
????boost::shared_ptr?viewer(
????????new?pcl::visualization::PCLVisualizer(?“Point?Cloud?Viewer“?)?);
????viewer->setCameraPosition(?0.0?0.0?-2.5?0.0?0.0?0.0?);
#endif
????//?Point?Cloud
????pcl::PointCloud::ConstPtr?cloud;
????//RANSAC
????pcl::PointCloud::Ptr?final(new?pcl::PointCloud);
????bool?is_plane?=?true;
????if?(pcl::console::find_argument(argc?argv?“-f“)?>=?0)
????{
????????is_plane?=?true;
????}
????else?if?(pcl::console::find_argument(argc?argv?“-sf“)?>=?0)
????{
????????is_plane?=?false;
????}
????std::vector?inliers;
????//?Retrieved?Point?Cloud?Callback?Function
????boost::mutex?mutex;
????boost::function::ConstPtr&?)>?function?=
????????[&cloud?&mutex?&is_plane?&final](?const?pcl::PointCloud::ConstPtr&?ptr?){
????????????boost::mutex::scoped_lock?lock(?mutex?);
????????????cloud?=?ptr;
????????????produced_frame_count_current++;
????????};
????//?Kinect2Grabber
????boost::shared_ptr?grabber?=?boost::make_shared();
????//?Register?Callback?Function
????boost::signals2::connection?connection?=?grabber->registerCallback(?function?);
????//?Start?Grabber
????grabber->start();
????DWORD?tick_start?tick_end;
????int?handled_frame_count_last?=?0?handled_frame_count_current?=?0?frame_count_before?=?0;
????tick_start?=?GetTickCount();
????
#ifdef?CLOUD_DISPLAY
????while(?!viewer->wasStopped()?){
????????//?Update?Viewer
????????viewer->spinOnce();
#else
????Sleep(100);
????while?(1)?{
#endif
????????if?(produced_frame_count_current?==?produced_frame_count_last)?{
????????????Sleep(1);
????????????continue;
????????}
????????produced_frame_count_last?=?produced_frame_count_current;
????????boost::mutex::scoped_try_lock?lock(?mutex?);
????????if?(cloud?&&?lock.owns_lock()){
????????????//?handle?cloud?here
????????????//?Create?the?filtering?object:?downsample?the?dataset?using?a?leaf?size?of?1cm
????????????pcl::PointCloud::Ptr?cloud_filtered(new?pcl::PointCloud);
????????????pcl::VoxelGrid?sor;
?????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......?????20266??2016-03-06?03:36??KinectGrabber-Kinect2Grabber\kinect2_grabber.h
????.......??????1100??2016-03-06?03:36??KinectGrabber-Kinect2Grabber\License.txt
????.......??????1358??2016-03-06?03:36??KinectGrabber-Kinect2Grabber\README.md
?????文件??????91483??2016-04-26?10:22??KinectGrabber-Kinect2Grabber\Sample\bin\ALL_BUILD.vcxproj
?????文件????????325??2016-04-26?10:22??KinectGrabber-Kinect2Grabber\Sample\bin\ALL_BUILD.vcxproj.filters
?????文件??????50806??2016-04-26?10:22??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeCache.txt
?????文件???????1954??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeCCompiler.cmake
?????文件???????2751??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeCXXCompiler.cmake
?????文件??????36864??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeDetermineCompilerABI_C.bin
?????文件??????36864??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeDetermineCompilerABI_CXX.bin
?????文件????????212??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeRCCompiler.cmake
?????文件????????395??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CMakeSystem.cmake
?????文件??????16967??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\CMakeCCompilerId.c
?????文件??????10240??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\CompilerIdC.exe
?????文件???????2403??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\CompilerIdC.vcxproj
?????文件???????2023??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CMakeCCompilerId.obj
?????文件????????776??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\cl.command.1.tlog
?????文件????????582??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\CL.read.1.tlog
?????文件????????516??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\CL.write.1.tlog
?????文件????????235??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\CompilerIdC.lastbuildstate
?????文件???????1090??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\li
?????文件???????2984??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\li
?????文件????????510??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\li
?????文件??????16939??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\CMakeCXXCompilerId.cpp
?????文件??????10752??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\CompilerIdCXX.exe
?????文件???????2411??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\CompilerIdCXX.vcxproj
?????文件???????2036??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\Debug\CMakeCXXCompilerId.obj
?????文件????????800??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\Debug\CompilerIdCXX.tlog\cl.command.1.tlog
?????文件????????594??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\Debug\CompilerIdCXX.tlog\CL.read.1.tlog
?????文件????????536??2016-04-26?10:21??KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdCXX\Debug\CompilerIdCXX.tlog\CL.write.1.tlog
............此處省略56個文件信息
- 上一篇:串口通信編程大全.pdf
- 下一篇:chrome史上最完整調用ocx完整解決方案
評論
共有 條評論