使用哪个 pcl 滤波器对点云进行下采样

Which pcl filter to use to downsample a point cloud

本文关键字:采样 pcl 滤波器      更新时间:2023-10-16

我从自动驾驶机器人的激光雷达中获得了点云,但要处理的数据太多了。

我已经实现了一个直通过滤器。

确实得到了一个非常好的结果,我问自己是否有其他过滤器或方法可以深入研究。

当然,我不是在寻找任何具体的东西,而是在寻找方向或建议,因为我对 pcl 库很陌生,而且它看起来很大。

这是我现在的过滤器:

    pcl::PointCloud<PointXYZIR>::Ptr cloudInput;
    cloudInput.reset(new pcl::PointCloud<PointXYZIR> (cloud_in));
    pcl::PointCloud<PointXYZIR>::Ptr cloudFiltered;
    cloudFiltered.reset(new pcl::PointCloud<PointXYZIR>);
    // Create the filtering object: downsample the dataset using a leaf size
    pcl::VoxelGrid<PointXYZIR> avg;
    avg.setInputCloud(cloudInput);
    avg.setLeafSize(0.25f, 0.25f, 0.25f);
    avg.filter(*cloudFiltered);
    //Filter object
    pcl::PassThrough<PointXYZIR> filter;
    filter.setInputCloud(cloudFiltered);
    filter.setFilterFieldName("x");
    filter.setFilterLimits(-100, 100);
    filter.filter(*cloudFiltered);
    filter.setFilterFieldName("y");
    filter.setFilterLimits(-100, 100);
    filter.filter(*cloudFiltered);
    cloud_out = *cloudFiltered;

素网格到下采样应该保持相当好的云分布,同时减少点数。 您可以设置每个轴中体素的最小程度,以便根据需要保持尽可能多或尽可能少的分辨率。 每个体素将删除其中的所有点,并将它们替换为从已删除的点取平均值的单个点。http://pointclouds.org/documentation/tutorials/voxel_grid.php#voxelgrid

实际上我确实找到了解决方案,但没有通用的解决方案。就我而言,我认为这个问题非常具体地取决于你将得到哪个点云以及你想用它做什么。

passtrought滤波器是一种非常有效的降样方法,而不会冒太多丢失有趣数据的风险。

http://pointclouds.org/documentation/tutorials/passthrough.php

然后我测试了StatalOutlierRemoval,它很有效,但与我的情况无关。

http://pointclouds.org/documentation/tutorials/statistical_outlier.php

现在,我使用叶大小函数对点云进行下采样,然后创建一个 kdtree 来按半径过滤点。这与passtrought过滤器的计算量大致相同,但在我的项目中,这样做更有意义。

 // Create the filtering object: downsample the dataset using a leaf size
    pcl::VoxelGrid<PointXYZIR> avg;
    avg.setInputCloud(cloudInput);
    avg.setLeafSize(0.25f, 0.25f, 0.25f);
    avg.filter(*cloudFiltered);
    //searchPoint
    PointXYZIR searchPoint = cloudFiltered->at(0) ;
    //result from radiusSearch()
    std::vector<int> pointIdxRadiusSearch;
    std::vector<float> pointRadiusSquaredDistance;
    //kdTree
    pcl::KdTreeFLANN<PointXYZIR> kdtree;
    kdtree.setInputCloud (cloudFiltered);
    kdtree.setSortedResults(true);
    if ( kdtree.radiusSearch (searchPoint, 100, pointIdxRadiusSearch, pointRadiusSquaredDistance) > 0 )
    {
        //delete every point in target
        for (size_t j = 0; j < pointIdxRadiusSearch.size (); ++j)
        {
            //is this the way to erase correctly???
            cloud_out.push_back(cloudFiltered->points[pointIdxRadiusSearch[j]]);
        }
    }