简介
点云过滤作为传统激光点云目标检测预处理阶段重要一环节,过滤效果的好坏会直接影响后续点云聚类检测的效果。现实无人车行驶的道路上,地形起伏坡度不一致,这就导致一般的点云过滤算法无法有效的处理像进入地下车库这种曲率特别大的路段。有些时候就需要一些先验信息辅助进行大曲率斜坡的过滤。本篇博客介绍一种结合地图给予的先验信息进行过滤的一种方法,能够有效的进行点云大斜坡过滤,同时还能够保证一定的实时性。
大曲率点云斜坡过滤
我们看下大曲率流程图:
代码分析
下面我们看下如下的demo示例:功能相对单一,代码比较简单。
#include <iostream>
#include <pcl/common/centroid.h>
#include <pcl/filters/crop_hull.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/sample_consensus/ransac.h>
#include <pcl/sample_consensus/sac_model_plane.h>
#include <pcl/filters/impl/plane_clipper3D.hpp>
class SlopeFilter
{
public:
using PointXYZ = pcl::PointXYZ;
using PCLPointCloud = pcl::PointCloud<pcl::PointXYZ>;
using PCLPointCloudPtr = pcl::PointCloud<pcl::PointXYZ>::Ptr;
// 构造函数初始化点集.
explicit SlopeFilter(std::vector<std::vector<PointXYZ>> slope_peak_points)
: region_cloud_(new PCLPointCloud)
{
slope_peak_points_ = slope_peak_points;
}
// 应用此函数进行斜坡滤波.
void ApplyFilter(const PCLPointCloudPtr inputCloud, PCLPointCloudPtr outputCloud)
{
PCLPointCloudPtr remain_pointcloud(new PCLPointCloud);
pcl::copyPointCloud(*inputCloud, *remain_pointcloud);
for (size_t i = 0U; i < slope_peak_points_.size(); ++i)
{
PCLPointCloudPtr temp_croped_cloud(new PCLPointCloud);
PCLPointCloudPtr temp_croped_outside_cloud(new PCLPointCloud);
PCLPointCloudPtr temp_clipped_cloud(new PCLPointCloud);
initSlopePlane(slope_peak_points_[i]);
cropSlopePlane(remain_pointcloud, temp_croped_cloud, temp_croped_outside_cloud);
if (0U == temp_croped_cloud->size())
{
continue;
}
pcl::copyPointCloud(*temp_croped_outside_cloud, *remain_pointcloud);
clipEachPlane(temp_croped_cloud, slope_peak_points_