【问题标题】:Removing points from a pcl::PointCloud<pcl::PointXYZRGB>从 pcl::PointCloud<pcl::PointXYZRGB> 中删除点
【发布时间】:2017-12-08 20:55:42
【问题描述】:

我是 PCL 的新手。我正在使用 PCL 库,并且正在寻找一种从点云中提取点或将特定点复制到新点的方法。我想验证每个点是否符合条件,并且我想获得一个只有好的点的点云。谢谢!

【问题讨论】:

  • 欢迎来到 StackOverflow。请发布您已经尝试过的代码以及您的具体问题所在。

标签: c++ ros point-cloud-library point-clouds


【解决方案1】:

使用 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);

【讨论】:

    【解决方案2】:

    只需使用 pcl 迭代器进行逐点操作,假设您想在云中操作 W.R.T z 值,那么您可以这样做;

    for (pcl::PointCloud<pcl::PointXYZRGB>::iterator it = cloud_filtered->begin(); it != cloud_filtered->end(); it++) {
        if (it->z > 3.0) {
            cloud_filtered->erase(it);
        }
    }
    

    【讨论】:

      【解决方案3】:

      如果您不熟悉 PCL。看看文档应该是个好主意:

      http://pointclouds.org/documentation/tutorials/

      我认为本教程中解释了您要查找的内容:

      http://pointclouds.org/documentation/tutorials/remove_outliers.php#remove-outliers

      尝试在您的机器上重现该示例,然后对其进行修改以满足您的需要。

      【讨论】:

      • 问题在于,对于每个点,我都有基于 z 坐标的不同条件。
      • 您的第二个链接返回错误 404。您有更新的链接吗?
      • 链接断开,回答没有帮助
      猜你喜欢
      • 2016-10-09
      • 1970-01-01
      • 2012-05-25
      • 1970-01-01
      • 1970-01-01
      • 2018-03-29
      • 2015-03-26
      • 1970-01-01
      • 2020-04-19
      相关资源
      最近更新 更多