PCL从点云PointCloud中减去目标点云PointCloud

该博客介绍了如何使用PCL库中的ExtractIndices类来删除点云中低于特定高度(平均高度)的点。通过遍历点云数据,计算点的Z坐标与平均值的差值,并将差值小于阈值的点的索引存储。然后,设置ExtractIndices过滤器,将负选中设置为true,从而移除这些点。最终通过filter()方法更新点云,得到去除目标点后的点云数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用ExtractIndices类:

  • 将要删除的点添加到PointIndices变量中
  • 将这些指数传递给ExtractIndices
  • 运行filter()方法
      pcl::PointCloud<pcl::PointXYZ>::Ptr p_obstacles(new pcl::PointCloud<pcl::PointXYZ>);
      pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
      pcl::ExtractIndices<pcl::PointXYZ> extract;
      for (int i = 0; i < (*p_obstacles).size(); i++)
      {
        pcl::PointXYZ pt(p_obstacles->points[i].x, p_obstacles->points[i].y, p_obstacles->points[i].z);
        float zAvg = 0.5f;
        if (abs(pt.z - zAvg) < THRESHOLD) // e.g. remove all pts below zAvg
        {
          inliers->indices.push_back(i);
        }
      }
      extract.setInputCloud(p_obstacles);
      extract.setIndices(inliers);
      extract.setNegative(true);
      extract.filter(*p_obstacles);
    获得减去目标点云的点云数据。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值