首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何利用PCL过滤kinect中的点云数据

如何利用PCL过滤kinect中的点云数据
EN

Stack Overflow用户
提问于 2012-05-25 03:41:03
回答 1查看 2.7K关注 0票数 0

我现在正在使用PCL和kinect,回调功能如下所示:

我想做一些过滤,但是我不能直接访问回调函数中的"cloud“,因为它是常量类型,所以我将它复制到"cloud2”以查看它是否有效。

结果是编译通过而运行时错误,有谁帮我吗?

代码语言:javascript
复制
class SimpleOpenNIProcessor
{
public:
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2;
     SimpleOpenNIProcessor () : viewer ("PCL OpenNI Viewer") {}
     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud)
  {

    *(cloud2)=*(cloud);
     if (!viewer.wasStopped())
         viewer.showCloud (cloud);

  }

  void run ()
  {

    // create a new grabber for OpenNI devices
    pcl::Grabber* interface = new pcl::OpenNIGrabber();

    // make callback function from member function
    boost::function<void (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr&)> f =
      boost::bind (&SimpleOpenNIProcessor::cloud_cb_, this, _1);

    // connect callback function for desired signal. In this case its a point cloud with color values
    boost::signals2::connection c = interface->registerCallback (f);

    // start receiving point clouds
    interface->start ();

    // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
    while (true)
      sleep(1);

    // stop the grabber
    interface->stop ();
  }
      pcl::visualization::CloudViewer viewer;

};

int main ()
{

  SimpleOpenNIProcessor v;
  v.run ();
  return (0);
}
EN

回答 1

Stack Overflow用户

发布于 2012-05-26 20:08:51

pcl::PointCloud::Ptr cloud2;

这只定义了cloud2,您还需要在堆上创建它,否则您将得到错误的内存访问(作为一个指针)。

代码语言:javascript
复制
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2( new pcl::PointCloud<pcl::PointXYZ>());

而且你不应该做

*cloud 2= *cloud;

这不是你应该使用的一种干净的复制方式。

代码语言:javascript
复制
pcl::copyPointCloud<PointT, PointT>(*cloud, *cloud2);

(我上面的答案也适用,你应该两者都做!)

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10748194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档