voxel_grid.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <pcl/io/pcd_io.h>
00003 #include <pcl/point_types.h>
00004 #include <pcl/filters/voxel_grid.h>
00005 
00006 int
00007 main (int argc, char** argv)
00008 {
00009   pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2 ());
00010   pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());
00011 
00012   // Fill in the cloud data
00013   pcl::PCDReader reader;
00014   // Replace the path below with the path where you saved your file
00015   reader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!
00016 
00017   std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height 
00018        << " data points (" << pcl::getFieldsList (*cloud) << ").";
00019 
00020   // Create the filtering object
00021   pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
00022   sor.setInputCloud (cloud);
00023   sor.setLeafSize (0.01f, 0.01f, 0.01f);
00024   sor.filter (*cloud_filtered);
00025 
00026   std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height 
00027        << " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";
00028 
00029   pcl::PCDWriter writer;
00030   writer.write ("table_scene_lms400_downsampled.pcd", *cloud_filtered, 
00031          Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), false);
00032 
00033   return (0);
00034 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:37:29