需要滤波:
- 噪声点
- 离散点
- 空洞
滤波处理算法:
- 双边滤波
- 高斯滤波
- 条件滤波
- 直通滤波
- 基于随机采样一致性滤波
二次配置PCL环境如何简便操作:
在笔记一中:PCL笔记一:Windows10安装PCL;与VS2019联合调试;保存点云为PCD文档。
我们对如何在vs中配置PCL进行了讲解。当我们需要重新开辟一个项目时,如何简单易行呢?
在VS中新建一个项目:比如02 滤波

打开属性管理器:对比两个项目:我们发现:新项目缺少PCL的配置。

如果想复用上一个项目中的配置

把这个文件复制到我们的新项目目录下:我们当时的命名是PCL1.12.0X64




至此配置完成。同一个电脑最简单有效,如果换一台电脑,要注意按照笔记一种方法添加配置。
直通滤波器对点云滤波
#include <iostream>
#include <ctime>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
int
main(int argc, char** argv)
{
srand(time(0));
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);
//填入点云数据
cloud->width = 5;
cloud->height = 1;
cloud->points.resize(cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size(); ++i)
{
cloud->points[i].x = rand() / (RAND_MAX + 1.0f) - 0.5;
cloud->points[i].y = rand() / (RAND_MAX + 1.0f) - 0.5;
cloud->points[i].z = rand() / (RAND_MAX + 1.0f) - 0.5;
}
std::cerr << "Cloud before filtering: " << std::endl;
for (size_t i = 0; i < cloud->points.size(); ++i)
std::cerr << " " << cloud->points[i].x << " "
<< cloud->points[i].y << " "
<< cloud->points[i].z << std::endl;
// 创建滤波器对象
pcl::PassThrough<pcl::PointXYZ> pass; // 滤波器对象。
pass.setInputCloud(cloud); // 设置输入点云
pass.setFilterFieldName("z"); // 过滤限定范围z字段轴。
pass.setFilterLimits(0.0, 1.0); // 过滤字段范围。
//pass.setFilterLimitsNegative (true); // 保留还是舍弃。true:符合条件保留。
pass.filter(*cloud_filtered); // 执行滤波,保存在cloud_filtered指针。
std::cerr << "Cloud after filtering: " << std::endl;
for (size_t i = 0; i < cloud_filtered->points.size(); ++i)
std::cerr << " " << cloud_filtered->points[i].x << " "
<< cloud_filtered->points[i].y << " "
<< cloud_filtered->points[i].z << std::endl;
return (0);
}
输出:
Cloud before filtering:
-0.0175171 -0.0680542 -0.306366
0.367126 -0.394836 0.212524
-0.36554 -0.488831 0.329926
0.397644 -0.489227 0.0578308
-0.248871 0.187042 0.274689
Cloud after filtering:
0.367126 -0.394836 0.212524
-0.36554 -0.488831 0.329926
0.397644 -0.489227 0.0578308
-0.248871 0.187042 0.274689
虽然是完成了。过滤,但是。这个程序会在程序执行完报错。目前想到的解决方案是try。
使用VoxelGrid滤波器对点云进行下采样
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/PCLPointCloud2.h>
int
main(int argc, char** argv)
{
pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2());
pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2());
// 填入点云数据
pcl::PCDReader reader;
// 把路径改为自己存放文件的路径
reader.read("C:\\Users\\1987wangsanguo\\Desktop\\PCD_Viewer\\PCD_Viewer\\2f_only_voxel.pcd", *cloud);
// 记住要事先下载这个数据集!
std::cerr << "PointCloud befor

本文详细介绍了点云滤波的各种方法,如双边滤波、高斯滤波、直通滤波、基于随机采样一致性滤波,以及针对PCL环境的二次配置。通过实例演示了直通滤波器去除噪声点和离散点,以及VoxelGrid和StatisticalOutlierRemoval滤波器的应用。此外,还涵盖了点云子集提取、参数化模型投影和复杂滤波器如ConditionalRemoval和RadiusOutlierRemoval。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



