从 pcl::P ointCloud<pcl::P ointXYZRGB 中删除点>
Removing points from a pcl::PointCloud<pcl::PointXYZRGB>
我是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
尝试在您的计算机上重现该示例,然后对其进行修改以满足您的需求。
相关文章:
- 将数组的地址分配给变量并删除
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- C/C++编译器通常会删除重复的库吗
- 从链接列表c++中删除一个项目
- C++如何通过用户输入删除列表元素
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- 使用函数"remove"删除重复元素
- 如何从多映射中删除特定的重复项
- 运算符C++ "delete []"仅删除 2 个前值
- 删除指向指针的指针是运行时错误吗
- 将指针设置为"nullptr"并不能防止双重删除?
- 为什么示例代码访问IUnknown中已删除的内存
- 删除 PCL 可视化工具中定义的 3D 框外部的点
- 从 pcl::P ointCloud<pcl::P ointXYZRGB 中删除点>
- PCL 和 CMake 的问题:链接时未定义统计异常值删除
- PCL 删除分段表下的点
- 提升指针PCL,用新的指针更新旧的指针并删除新的指针