实时过滤点云... PCL

时间:2014-11-09 07:58:22

标签: point-cloud-library kinect.toolbox

我想显示一个实时过滤的点云,我的意思是不是来自PCD文件,我一直在尝试操纵PCL文档中的示例代码,我是这个东西和c ++初学者的新手。这是我的代码,它有错误,但我无法理解。 :(

#include <pcl/io/openni_grabber.h>
#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
Class SimpleOpenNIViewer
{
 public:
 SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}
 pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_filtered;
 void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud)
 {
   if (!viewer.wasStopped()){
     pcl::VoxelGrid<pcl::PointCloud<pcl::PointXYZ> sor;
     sor.setInputCloud (cloud);
     sor.setLeafSize (0.01f, 0.01f, 0.01f);
     sor.filter (*cloud_filtered);
     viewer.showCloud (cloud_filtered);
   }
 }

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

   boost::function<void (const pcl::PointCloud<pcl::PointXYZ>::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;
}

1 个答案:

答案 0 :(得分:0)

错误:

sor.setInputCloud (cloud);
sor.setLeafSize (0.01f, 0.01f, 0.01f);
sor.filter (*cloud_filtered);
viewer.showCloud (*cloud_filtered);// I guess with this the error is solved