Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <pcl/features/statistical_multiscale_interest_region_extraction.h>
00039 #include <pcl/io/pcd_io.h>
00040 #include <pcl/filters/voxel_grid.h>
00041 #include <pcl/filters/extract_indices.h>
00042
00043
00044 using namespace pcl;
00045 using namespace std;
00046
00047 const float subsampling_leaf_size = 0.003f;
00048 const float base_scale = 0.005f;
00049
00050
00051 int
00052 main (int, char **argv)
00053 {
00054 PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
00055
00056 PCDReader reader;
00057 reader.read (argv[1], *cloud);
00058 PCL_INFO ("Cloud read: %s\n", argv[1]);
00059 cerr << "cloud has #points: " << cloud->points.size () << endl;
00060
00061 PointCloud<PointXYZ>::Ptr cloud_subsampled (new PointCloud<PointXYZ> ());
00062 VoxelGrid<PointXYZ> subsampling_filter;
00063 subsampling_filter.setInputCloud (cloud);
00064 subsampling_filter.setLeafSize (subsampling_leaf_size, subsampling_leaf_size, subsampling_leaf_size);
00065 subsampling_filter.filter (*cloud_subsampled);
00066 cerr << "subsampled cloud has #points: " << cloud_subsampled->points.size () << endl;
00067
00068 StatisticalMultiscaleInterestRegionExtraction<PointXYZ> region_extraction;
00069 std::vector<float> scale_vector;
00070 PCL_INFO ("Scale values that will be used: ");
00071 float base_scale_aux = base_scale;
00072 for (size_t scales = 0; scales < 7; ++scales)
00073 {
00074 PCL_INFO ("%f ", base_scale_aux);
00075 scale_vector.push_back (base_scale_aux);
00076 base_scale_aux *= 1.6f;
00077 }
00078 PCL_INFO ("\n");
00079 region_extraction.setInputCloud (cloud_subsampled);
00080 region_extraction.setScalesVector (scale_vector);
00081 std::list<IndicesPtr> rois;
00082 region_extraction.computeRegionsOfInterest (rois);
00083
00084 PCL_INFO ("Regions of interest found: %d\n", rois.size ());
00085 pcl::ExtractIndices<PointXYZ> extract_indices_filter;
00086 unsigned int roi_count = 0;
00087 for (std::list<IndicesPtr>::iterator l_it = rois.begin (); l_it != rois.end (); ++l_it)
00088 {
00089 PointCloud<PointXYZ> roi_points;
00090 extract_indices_filter.setInputCloud (cloud_subsampled);
00091 extract_indices_filter.setIndices (*l_it);
00092 extract_indices_filter.filter (roi_points);
00093
00094 char filename[512];
00095 sprintf (filename, "roi_%03d.pcd", ++roi_count);
00096 io::savePCDFileASCII (filename, roi_points);
00097 }
00098
00099 io::savePCDFileASCII ("subsampled_input.pcd", *cloud_subsampled);
00100
00101 return 0;
00102 }