首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么过滤后的VoxelGrid只给我一个云端的点数?

为什么过滤后的VoxelGrid只给我一个云端的点数?
EN

Stack Overflow用户
提问于 2020-07-05 20:30:37
回答 1查看 389关注 0票数 1

我正在接收ROS消息,类型为

代码语言:javascript
复制
sensor_msgs::PointCloud2ConstPtr

在我的回调函数中,我将它转换为

代码语言:javascript
复制
pcl::PointCloud<pcl::PointXYZ>::Ptr

使用函数

代码语言:javascript
复制
pcl::fromROSMsg.

之后,使用pcl教程中的代码进行正常估计:

代码语言:javascript
复制
void OrganizedCloudToNormals(
      const pcl::PointCloud<pcl::PointXYZ>::Ptr &_inputCloud,
      pcl::PointCloud<pcl::PointNormal>::Ptr &cloud_normals
      )
{ 
      pcl::console::print_highlight ("Estimating scene normals...\n");
      pcl::NormalEstimationOMP<pcl::PointXYZ,pcl::PointNormal> nest;
      nest.setRadiusSearch (0.001);
      nest.setInputCloud (_inputCloud);
      nest.compute (*cloud_normals);
    
      //write 0 wherever is NaN as value
      for(int i=0; i < cloud_normals->points.size(); i++)
      {
        cloud_normals->points.at(i).normal_x = isnan(cloud_normals->points.at(i).normal_x) ? 0 : cloud_normals->points.at(i).normal_x;
        cloud_normals->points.at(i).normal_y = isnan(cloud_normals->points.at(i).normal_y) ? 0 : cloud_normals->points.at(i).normal_y;
        cloud_normals->points.at(i).normal_z = isnan(cloud_normals->points.at(i).normal_z) ? 0 : cloud_normals->points.at(i).normal_z;
        cloud_normals->points.at(i).curvature = isnan(cloud_normals->points.at(i).curvature) ? 0 : cloud_normals->points.at(i).curvature;
      }
}

之后,我得到了pcl::PointNormal类型的点云,并尝试对其进行下采样

代码语言:javascript
复制
const float leaf = 0.001f; //0.005f;
pcl::VoxelGrid<pcl::PointNormal> gridScene;
gridScene.setLeafSize(leaf, leaf, leaf);
gridScene.setInputCloud(_scene);
gridScene.filter(*_scene);

其中_scene的类型为

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

然后经过过滤,我最终得到了我的点云_scene,它里面只有一个点。我试着改变树叶的大小,但这并没有改变结果。

有人知道我做错了什么吗?

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-07 16:52:37

我找到问题出在哪里了。类型pcl::PoinNormal有字段x,y,z,normal_x,normal_y和normal_z,但在我的函数OrganizedCloudToNormals中,我只填充了字段normal_x,normal_y和normal_z,字段x,y和z的每个点都有值0。当我从输入点云中填充字段x,y和z时,过滤(下采样)问题消失了,我已经过滤了内部超过1个点的云。在x,y和z字段中缺少值可能会导致稍后在体素网格对象的filter方法中出现问题。

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

https://stackoverflow.com/questions/62740730

复制
相关文章

相似问题

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