首先,下载数据集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