点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 3800|回复: 1

如何用Kinect获取数据,用于后续操作

[复制链接]
发表于 2017-1-25 10:33:54 | 显示全部楼层 |阅读模式
大家过年好!
问一个问题。之前代码用的都是现成的.pcd文件,现在有需要从kinect获取数据来进行实验。已经实现了openni grabber和viewer功能,想知道如何能在代码中调取Kinect的点云数据进行相关的操作。或者,是否可以将其存为.pcd文件,方便调用呢?十分感谢
我想要用kinect获取.pcd文件,但是pcl只有使用已经存盘的.pcd文件的教程和可视化教程。有没有人能给一些指点,给一个正确的方向,十分感谢!
我的可视化代码如下:
#include <pcl/io/openni2_grabber.h>
#include <pcl/visualization/cloud_viewer.h>

class SimpleOpenNIViewer
{
public:
        SimpleOpenNIViewer() : viewer("PCL OpenNI Viewer") {}

        void cloud_cb_(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
        {
                if (!viewer.wasStopped())
                        viewer.showCloud(cloud);
        }

        void run()
        {
                pcl::Grabber* interface = new pcl::io::OpenNI2Grabber();

                boost::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
                        boost::bind(&SimpleOpenNIViewer::cloud_cb_, this, _1);

                interface->registerCallback(f);

                interface->start();

                while (!viewer.wasStopped())
                {
                        boost::this_thread::sleep(boost::posix_time::seconds(1));
                }

                interface->stop();
        }

        pcl::visualization::CloudViewer viewer;
};

int main()
{
        SimpleOpenNIViewer v;
        v.run();
        return 0;
}

回复

使用道具 举报

发表于 2017-8-18 10:07:55 | 显示全部楼层
题主解决了吗
回复 支持 反对

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-4-20 14:56 , Processed in 1.662880 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表