PCL中UniformSampling和VoxelGrid的区别

10 篇文章 11 订阅

均匀下采样(UniformSampling)

代码中的描述如下:

  /** \brief @b UniformSampling assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
    *
    * The @b UniformSampling class creates a *3D voxel grid* (think about a voxel
    * grid as a set of tiny 3D boxes in space) over the input point cloud data.
    * Then, in each *voxel* (i.e., 3D box), all the points present will be
    * approximated (i.e., *downsampled*) with the closest point to the center of the voxel.
    *
    * \author Radu Bogdan Rusu
    * \ingroup filters
    */

先划分体素,然后在每个体素中选取一个离体素的几何中心最近的点。

体素下采样(VoxelGrid)

代码中的描述如下:

  /** \brief VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
    *
    * The VoxelGrid class creates a *3D voxel grid* (think about a voxel
    * grid as a set of tiny 3D boxes in space) over the input point cloud data.
    * Then, in each *voxel* (i.e., 3D box), all the points present will be
    * approximated (i.e., *downsampled*) with their centroid. This approach is
    * a bit slower than approximating them with the center of the voxel, but it
    * represents the underlying surface more accurately.
    *
    * \author Radu B. Rusu, Bastian Steder
    * \ingroup filters
    */

先划分体素,然后计算每个体素的质心坐标,每个体素仅保留质心点。
downsample_all_data_ == false则直接计算每个体素中所有点云的XYZ均值,得到的点云仅有XYZ变量。
downsample_all_data_ == true则使用pcl::CentroidPoint<PointT>实现每个体素中所有点云的XYZRGB的均值计算。
pcl::CentroidPoint<PointT>中的pcl::detail::Accumulators<PointT>::type无法识别除XYZRGB以外的自定义类型。也因为如此,PCL中实现的体素下采样无法保留除颜色以外的其他点云特征。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PCL,可以使用VoxelGrid滤波器对点云进行降采样操作。VoxelGrid滤波器将点云划分为一个个体素(Voxel),并将每个体素内的点云数据压缩为一个单独的代表点。 以下是在PCL使用VoxelGrid滤波器进行点云采样的示例代码: ```cpp #include <pcl/point_cloud.h> #include <pcl/filters/voxel_grid.h> pcl::PointCloud<pcl::PointXYZ>::Ptr downsamplePointCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, float leaf_size) { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_downsampled(new pcl::PointCloud<pcl::PointXYZ>); pcl::VoxelGrid<pcl::PointXYZ> voxelgrid; voxelgrid.setInputCloud(cloud); voxelgrid.setLeafSize(leaf_size, leaf_size, leaf_size); voxelgrid.filter(*cloud_downsampled); return cloud_downsampled; } ``` 在上述示例,我们首先创建了输入点云 `cloud` 和输出点云 `cloud_downsampled`。然后,我们创建了一个 `pcl::VoxelGrid` 对象 `voxelgrid`,并设置了输入点云。 使用 `setLeafSize` 方法,我们设置了体素的大小,即 `leaf_size`。体素的大小决定了降采样后的点云密度,较小的体素大小会产生更多的点云数据,较大的体素大小则会减少点云数据。 最后,通过调用 `filter` 方法,我们对点云进行了降采样操作,并将结果保存到 `cloud_downsampled` ,并返回该点云。 你可以根据需要调整体素的大小,以获得所需的降采样效果。这样,你就可以使用VoxelGrid滤波器对点云进行降采样了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值