0

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

1 回答 1

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
于 2015-09-28T11:35:20.637 回答