从pcl :: PointCloud< pcl :: PointXYZRGB>中删除点 [英] Removing points from a pcl::PointCloud<pcl::PointXYZRGB>
本文介绍了从pcl :: PointCloud< pcl :: PointXYZRGB>中删除点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是PCL的新手.我正在使用PCL库,正在寻找一种从点云中提取点或将特定点复制到新点的方法.我想验证每个点是否符合条件,并且我想获得只包含好点的点云.谢谢!
I'm new in PCL. I'm using the PCL library and I'm looking for a way to extract points from a point cloud or copying particular points to a new one. I want to verify for each point if it respects a condition and I want to obtain a point cloud with only the good points.Thank you!
推荐答案
使用ExtractIndices类:
Use the ExtractIndices class:
- 将要删除的点添加到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 :: PointCloud< pcl :: PointXYZRGB>中删除点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文