Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Voxelizing in PCL is simply accomplished: the voxelizer is a filter, and it takes a point cloud as an input. It then outputs the voxelized point cloud, calculated for the centroid of the set of points voxelized. See Listing 6-1 for an example.
Listing 6-1. Voxelizing Data
#include <pcl/filters/voxel_grid.h>
//Voxelization
pcl::VoxelGrid<pcl::PointXYZRGB> vox;
vox.setInputCloud (point_cloud_ptr);
vox.setLeafSize (5.0f, 5.0f, 5.0f);
vox.filter (*cloud_filtered);
std::cerr << "PointCloud before filtering: " << point_cloud_ptr->width *
point_cloud_ptr->height << " data points (" << pcl::getFieldsList (*point_cloud_ptr) << ").";
std::cerr << "PointCloud after filtering: " << cloud_filtered->width *
cloud_filtered->height << " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";