profile_plane_extraction.cpp
Go to the documentation of this file.
00001 
00063 // PCL:
00064 #include <pcl/point_types.h>
00065 #include <pcl/io/pcd_io.h>
00066 #include <pcl/common/file_io.h>
00067 #include <pcl/filters/voxel_grid.h>
00068 
00069 // stack includes:
00070 #include "cob_3d_mapping_common/stop_watch.h"
00071 #include "cob_3d_mapping_common/point_types.h"
00072 #include "cob_3d_segmentation/plane_extraction.h"
00073 
00074 
00075 typedef pcl::PointXYZRGB PointT;
00076 
00077 class PerformanceTester
00078 {
00079 public:
00080   PerformanceTester()
00081     : p_vox(new pcl::PointCloud<PointT>)
00082   {
00083     voxel.setLeafSize(0.03,0.03,0.03);
00084     pe.setSaveToFile(false);
00085     pe.setClusterTolerance(0.06);
00086     pe.setMinPlaneSize(50);
00087     pe.setAlpha(0.2);
00088   }
00089 
00090   void
00091   computeForOneCloud(pcl::PointCloud<PointT>::ConstPtr cloud)
00092   {
00093     PrecisionStopWatch t;
00094     t.precisionStart();
00095     voxel.setInputCloud(cloud);
00096     voxel.filter(*p_vox);
00097     std::cout << t.precisionStop() << " | ";
00098     t.precisionStart();
00099     pe.extractPlanes(p_vox, v_cloud_hull, v_hull_polygons, v_coefficients_plane);
00100     std::cout << t.precisionStop() << std::endl;
00101   }
00102 
00103 private:
00104   pcl::PointCloud<PointT>::Ptr p_vox;
00105   std::vector<pcl::PointCloud<PointT>, Eigen::aligned_allocator<pcl::PointCloud<PointT> > > v_cloud_hull;
00106   std::vector<std::vector<pcl::Vertices> > v_hull_polygons;
00107   std::vector<pcl::ModelCoefficients> v_coefficients_plane;
00108 
00109   pcl::VoxelGrid<PointT> voxel;
00110   PlaneExtraction pe;
00111 
00112 };
00113 
00114 int main (int argc, char** argv)
00115 {
00116   if (argc != 2)
00117   {
00118     std::cout << "Please provide a folder containing multiple pcd files" << std::endl;
00119     return 0;
00120   }
00121 
00122   PerformanceTester pt;
00123   pcl::PCDReader r;
00124   std::vector<std::string> files;
00125   pcl::getAllPcdFilesInDirectory(argv[1], files);
00126   std::vector<pcl::PointCloud<PointT>::Ptr> clouds;
00127   for (std::vector<std::string>::iterator it = files.begin(); it != files.end(); ++it)
00128   {
00129     clouds.push_back(pcl::PointCloud<PointT>::Ptr(new pcl::PointCloud<PointT>));
00130     r.read( argv[1] + *it, *(clouds.back()) );
00131   }
00132 
00133   int i = 0;
00134   while (i < 20)
00135   {
00136     std::vector<pcl::PointCloud<PointT>::Ptr>::iterator p = clouds.begin();
00137     std::cout << "Run #"<< i << std::endl;
00138     while(p != clouds.end())
00139     {
00140       pt.computeForOneCloud(*p);
00141       ++p;
00142     }
00143     ++i;
00144   }
00145 
00146   return 0;
00147 }


cob_3d_segmentation
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:03:03