首先,下载数据集table_scene_lms400.pcd
创建voxel_grid.cpp文件
源码:
1#include <iostream>
2#include <pcl/io/pcd_io.h>
3#include <pcl/point_types.h>
4#include <pcl/filters/voxel_grid.h>
5
6int
7main ()
8{
9 pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2 ());
10 pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());
11
12 // Fill in the cloud data
13 pcl::PCDReader reader;
14 // Replace the path below with the path where you saved your file
15 reader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!
16
17 std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height
18 << " data points (" << pcl

本文介绍了如何利用pcl库中的VoxelGrid体素化网格方法对点云数据进行下采样。首先,下载table_scene_lms400.pcd数据集,然后在voxel_grid.cpp文件中创建点云对象并读取数据。接着,设置体素大小为1厘米的过滤器,并应用到点云上。最后,将处理后的数据写入文件。通过修改CMakeLists.txt并运行程序,可以观察到下采样效果。
最低0.47元/天 解锁文章

507

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



