资源简介

完成的功能有:三维点云获取,点云数据下采样(为后续处理加速),平面检测和获取,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\link.command.1.tlog

     文件       2984  2016-04-26 10:21  KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\link.read.1.tlog

     文件        510  2016-04-26 10:21  KinectGrabber-Kinect2Grabber\Sample\bin\CMakeFiles\3.5.1\CompilerIdC\Debug\CompilerIdC.tlog\link.write.1.tlog

     文件      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个文件信息

评论

共有 条评论