从 pcl::P ointCloud<pcl::P ointXYZRGB 中删除点>

Removing points from a pcl::PointCloud<pcl::PointXYZRGB>

本文关键字:pcl 删除 gt lt ointCloud ointXYZRGB      更新时间:2023-10-16

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

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

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

如果您是 PCL 的新手。查看文档应该是一个好主意:

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

我认为本教程中解释了您正在寻找的内容:

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

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