实时过滤点云..PCL



我想显示一个实时过滤的点云,我的意思是不是来自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;
}

错误:

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

最新更新