PCL+Xtion 采集并显示点云图像

平台:PCL1.7.1 vs2010

硬件:华硕Xtion

显示采集的点云数据并保存为pcd格式:

代码如下:

#include <pcl/io/openni_grabber.h> #include <pcl/visualization/cloud_viewer.h> #include <pcl/io/pcd_io.h>#include <iostream>#include <string>#include <strstream>#include <pcl/common/time.h>#include <pcl/console/parse.h>class SimpleOpenNIViewer { public:SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud){if (!viewer.wasStopped()){viewer.showCloud (cloud); std::stringstream ss;ss << std::setprecision (12) << pcl::getTime () * 100 << ".pcd";pcl::PCDWriter w;w.writeBinaryCompressed (ss.str (), *cloud);}}void run (){pcl::Grabber* interface = new pcl::OpenNIGrabber();boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::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; }

,筑起梦想的鸟巢,开始人生的长跑,领先每回的冲刺,

PCL+Xtion 采集并显示点云图像

相关文章:

你感兴趣的文章:

标签云: