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

被折叠的 条评论
为什么被折叠?



