passthrough.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <pcl/point_types.h>
00003 #include <pcl/filters/passthrough.h>
00004 
00005 int
00006  main (int argc, char** argv)
00007 {
00008   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
00009   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
00010 
00011   // Fill in the cloud data
00012   cloud->width  = 5;
00013   cloud->height = 1;
00014   cloud->points.resize (cloud->width * cloud->height);
00015 
00016   for (size_t i = 0; i < cloud->points.size (); ++i)
00017   {
00018     cloud->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
00019     cloud->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
00020     cloud->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
00021   }
00022 
00023   std::cerr << "Cloud before filtering: " << std::endl;
00024   for (size_t i = 0; i < cloud->points.size (); ++i)
00025     std::cerr << "    " << cloud->points[i].x << " " 
00026                         << cloud->points[i].y << " " 
00027                         << cloud->points[i].z << std::endl;
00028 
00029   // Create the filtering object
00030   pcl::PassThrough<pcl::PointXYZ> pass;
00031   pass.setInputCloud (cloud);
00032   pass.setFilterFieldName ("z");
00033   pass.setFilterLimits (0.0, 1.0);
00034   //pass.setFilterLimitsNegative (true);
00035   pass.filter (*cloud_filtered);
00036 
00037   std::cerr << "Cloud after filtering: " << std::endl;
00038   for (size_t i = 0; i < cloud_filtered->points.size (); ++i)
00039     std::cerr << "    " << cloud_filtered->points[i].x << " " 
00040                         << cloud_filtered->points[i].y << " " 
00041                         << cloud_filtered->points[i].z << std::endl;
00042 
00043   return (0);
00044 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:42