region_grow_pcl17.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <vector>
00003 #include <pcl/point_types.h>
00004 #include <pcl/io/pcd_io.h>
00005 #include <pcl/search/search.h>
00006 #include <pcl/search/kdtree.h>
00007 #include <pcl/visualization/cloud_viewer.h>
00008 #include <pcl/filters/passthrough.h>
00009 #include <pcl/segmentation/region_growing_rgb.h>
00010 
00011 int
00012 main (int argc, char** argv)
00013 {
00014   pcl::search::Search <pcl::PointXYZRGB>::Ptr tree = boost::shared_ptr<pcl::search::Search<pcl::PointXYZRGB> > (new pcl::search::KdTree<pcl::PointXYZRGB>);
00015 
00016   pcl::PointCloud <pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud <pcl::PointXYZRGB>);
00017   if ( pcl::io::loadPCDFile <pcl::PointXYZRGB> ("region_growing_rgb_tutorial.pcd", *cloud) == -1 )
00018   {
00019     std::cout << "Cloud reading failed." << std::endl;
00020     return (-1);
00021   }
00022 
00023   pcl::IndicesPtr indices (new std::vector <int>);
00024   pcl::PassThrough<pcl::PointXYZRGB> pass;
00025   pass.setInputCloud (cloud);
00026   pass.setFilterFieldName ("z");
00027   pass.setFilterLimits (0.0, 1.0);
00028   pass.filter (*indices);
00029 
00030   pcl::RegionGrowingRGB<pcl::PointXYZRGB> reg;
00031   reg.setInputCloud (cloud);
00032   reg.setIndices (indices);
00033   reg.setSearchMethod (tree);
00034   reg.setDistanceThreshold (10);
00035   reg.setPointColorThreshold (6);
00036   reg.setRegionColorThreshold (5);
00037   reg.setMinClusterSize (600);
00038 
00039   std::vector <pcl::PointIndices> clusters;
00040   reg.extract (clusters);
00041 
00042   pcl::PointCloud <pcl::PointXYZRGB>::Ptr colored_cloud = reg.getColoredCloud ();
00043   pcl::visualization::CloudViewer viewer ("Cluster viewer");
00044   viewer.showCloud (colored_cloud);
00045   while (!viewer.wasStopped ())
00046   {
00047     boost::this_thread::sleep (boost::posix_time::microseconds (100));
00048   }
00049 
00050   return (0);
00051 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


furniture_classification
Author(s): Vladyslav Usenko
autogenerated on Thu May 23 2013 18:32:29