从pcl :: PointCloud <pcl :: PointXYZRGB>中删除点

mrx*_*mrx 1 c++ point-clouds ros point-cloud-library

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

Wol*_*ulz 14

使用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);
Run Code Online (Sandbox Code Playgroud)