• 大小: 58KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签: KinectFusion  

资源简介

经过优化的KinectFusion开源实现,无需PCL点云库,只要有opencv2.4.9即可运行。代码已经简化,适合对照论文学习算法。

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
#include 

using namespace kfusion;

struct KinFuApp
{
    static void KeyboardCallback(const cv::viz::KeyboardEvent& event void* pthis)
    {
        KinFuApp& kinfu = *static_cast(pthis);

        if(event.action != cv::viz::KeyboardEvent::KEY_DOWN)
            return;

        if(event.code == ‘t‘ || event.code == ‘T‘)
            kinfu.take_cloud(*kinfu.kinfu_);

        if(event.code == ‘i‘ || event.code == ‘I‘)
            kinfu.iteractive_mode_ = !kinfu.iteractive_mode_;
    }

    KinFuApp(OpenNISource& source) : exit_ (false)  iteractive_mode_(false) capture_ (source)
    {
        KinFuParams params = KinFuParams::default_params();
        kinfu_ = KinFu::Ptr( new KinFu(params) );

        capture_.setRegistration(true);

        cv::viz::WCube cube(cv::Vec3d::all(0) cv::Vec3d(params.volume_size) true cv::viz::Color::apricot());
        viz.showWidget(“cube“ cube params.volume_pose);
        viz.showWidget(“coor“ cv::viz::WCoordinateSystem(0.1));
        viz.registerKeyboardCallback(KeyboardCallback this);
    }

    void show_depth(const cv::Mat& depth)
    {
        cv::Mat display;
        //cv::normalize(depth display 0 255 cv::NORM_MINMAX CV_8U);
        depth.convertTo(display CV_8U 255.0/4000);
        cv::imshow(“Depth“ display);
    }

    void show_raycasted(KinFu& kinfu)
    {
        const int mode = 3;
        if (iteractive_mode_)
            kinfu.renderImage(view_device_ viz.getViewerPose() mode);
        else
            kinfu.renderImage(view_device_ mode);

        view_host_.create(view_device_.rows() view_device_.cols() CV_8UC4);
        view_device_.download(view_host_.ptr() view_host_.step);
        cv::imshow(“Scene“ view_host_);
    }

    void take_cloud(KinFu& kinfu)
    {
        cuda::DeviceArray cloud = kinfu.tsdf().fetchCloud(cloud_buffer);
        cv::Mat cloud_host(1 (int)cloud.size() CV_32FC4);
        cloud.download(cloud_host.ptr());
        viz.showWidget(“cloud“ cv::viz::WCloud(cloud_host));
        //viz.showWidget(“cloud“ cv::viz::WPaintedCloud(cloud_host));
    }

    bool execute()
    {
        KinFu& kinfu = *kinfu_;
        cv::Mat depth image;
        double time_ms = 0;
        bool has_image = false;

        for (int i = 0; !exit_ && !viz.wasStopped(); ++i)
        {
            bool has_frame = capture_.grab(depth image);
            if (!has_frame)
                return std::cout << “Can‘t grab“ << std::endl false;

            depth_device_.upload(depth.data depth.step depth.rows depth.cols);

            {
                SampledScopeTime fps(time_ms); (void)fps;
                has_image = kinfu(depth_device_);
            }

            if (has_image)
                show_raycasted(kinfu);

            show_depth(depth);
            //cv::ims

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-15 23:19  kinfu_remake-master\
     文件        1582  2014-04-15 23:19  kinfu_remake-master\CMakeLists.txt
     文件        1492  2014-04-15 23:19  kinfu_remake-master\LICENSE.md
     文件        1116  2014-04-15 23:19  kinfu_remake-master\README.md
     目录           0  2014-04-15 23:19  kinfu_remake-master\apps\
     文件         454  2014-04-15 23:19  kinfu_remake-master\apps\CMakeLists.txt
     文件        4863  2014-04-15 23:19  kinfu_remake-master\apps\demo.cpp
     目录           0  2014-04-15 23:19  kinfu_remake-master\cmake\
     目录           0  2014-04-15 23:19  kinfu_remake-master\cmake\Modules\
     文件        2830  2014-04-15 23:19  kinfu_remake-master\cmake\Modules\FindOpenNI.cmake
     文件        2761  2014-04-15 23:19  kinfu_remake-master\cmake\Modules\FindOpenNI2.cmake
     文件        4671  2014-04-15 23:19  kinfu_remake-master\cmake\Targets.cmake
     文件        3083  2014-04-15 23:19  kinfu_remake-master\cmake\Utils.cmake
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\
     文件         222  2014-04-15 23:19  kinfu_remake-master\kfusion\CMakeLists.txt
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\include\
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\include\io\
     文件         971  2014-04-15 23:19  kinfu_remake-master\kfusion\include\io\capture.hpp
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\
     文件       14543  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\device_array.hpp
     文件       10616  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\device_memory.hpp
     文件        1377  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\imgproc.hpp
     文件        2548  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\kernel_containers.hpp
     文件        1671  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\projective_icp.hpp
     文件        2277  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\cuda\tsdf_volume.hpp
     文件         177  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\exports.hpp
     文件        2941  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\kinfu.hpp
     文件        2154  2014-04-15 23:19  kinfu_remake-master\kfusion\include\kfusion\types.hpp
     目录           0  2014-04-15 23:19  kinfu_remake-master\kfusion\src\
     文件        7266  2014-04-15 23:19  kinfu_remake-master\kfusion\src\capture.cpp
............此处省略17个文件信息

评论

共有 条评论