00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00027 00028 #ifndef _PCL_REGION_GROWING_H_ 00029 #define _PCL_REGION_GROWING_H_ 00030 00038 #include <iostream> 00039 #include <vector> 00040 #include <algorithm> 00041 00042 #include <pcl/common/common.h> 00043 #include <pcl/point_cloud.h> 00044 #include <pcl/point_types.h> 00045 #include <pcl/octree/octree.h> 00046 #include <pcl/kdtree/kdtree_flann.h> 00047 #include <pcl/filters/extract_indices.h> 00048 #include <pcl/octree/octree.h> 00049 00050 using namespace pcl; 00051 using namespace std; 00052 00062 typedef struct 00063 { 00064 bool cloud_in_set; 00065 bool seeds_in_set; 00066 bool ok_to_run; 00067 bool run_finished; 00068 }TYPE_flags; 00069 00070 00074 template<class T, class T1> 00075 class region_growing 00076 { 00077 public: 00078 region_growing() 00079 { 00080 // reset the variables 00081 min_neighbors=5; 00082 00083 // reset flags 00084 flags.cloud_in_set=false; 00085 flags.seeds_in_set=false; 00086 flags.run_finished=false; 00087 flags.ok_to_run=false; 00088 }; 00089 00090 ~region_growing() 00091 { 00092 00093 } 00094 00098 00099 float radius; 00100 00102 int min_neighbors; 00103 00107 00108 void set_input_cloud(typename PointCloud<T>::Ptr cloud_in); 00109 00111 void set_input_seeds(typename PointCloud<T1>::Ptr seeds_in); 00112 00114 void filter (); 00115 00117 vector<int> get_region_indices(void); 00118 00120 PointIndices get_region_point_indices(void); 00121 00122 private: 00126 00127 TYPE_flags flags; 00128 00130 std::vector<int> region_indices; 00131 00133 PointIndices region_point_indices; 00134 00136 std::vector<int> search_list; 00137 00139 typename PointCloud<T>::Ptr cloud; 00140 00142 typename PointCloud<T1>::Ptr seeds; 00143 00145 PointCloud<T> region; 00146 00147 // KdTreeFLANN<T> tree; 00148 00152 00154 void process_flags(); 00155 00157 void extract_region_indices(); 00158 }; 00159 00160 #include "region_growing.hpp" 00161 #endif