gpt4 book ai didi

c++ - 从 pcl::PointCloud 中删除点

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:10:43 39 4
gpt4 key购买 nike

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

最佳答案

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

关于c++ - 从 pcl::PointCloud<pcl::PointXYZRGB> 中删除点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44921987/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com