28 #ifndef _PCL_REGION_GROWING_HPP_
29 #define _PCL_REGION_GROWING_HPP_
38 #define PFLN printf("LINE=%d in FUNCTION=%s\n",__LINE__,__FUNCTION__);
42 template<
class T,
class T1>
46 flags.cloud_in_set=
true;
50 template<
class T,
class T1>
54 flags.seeds_in_set=
true;
58 template<
class T,
class T1>
62 if (flags.cloud_in_set && flags.seeds_in_set)
67 cout <<
"ERROR: MUST SET PROPERLY A POSITIVE RADIUS THRESHOLD" << endl;
68 if (!flags.cloud_in_set)
69 cout <<
"ERROR: MUST SET PROPERLY A INPUT CLOUD DATA" << endl;
70 if (!flags.seeds_in_set)
71 cout <<
"ERROR: MUST SET PROPERLY A INPUT SEED CLOUD DATA" << endl;
75 template<
class T,
class T1>
78 if (flags.run_finished)
79 return region_indices;
88 template<
class T,
class T1>
91 if (flags.run_finished)
93 region_point_indices.indices=region_indices;
94 return region_point_indices;
99 empty.indices.push_back(0);
106 template<
class T,
class T1>
117 vector<int> queue_list;
123 static KdTreeFLANN<T> tree;
124 tree.setInputCloud (cloud);
130 vector<bool> processed ((
int)cloud->points.size(),
false);
131 vector<bool> processed_init ((
int)cloud->points.size(),
false);
136 for (
size_t i=0; i<seeds->points.size(); ++i)
138 std::vector<float> pointRadiusSquaredDistance;
139 std::vector<int> pointIdxRadiusSearch;
140 searchPoint.x=seeds->points[i].x;
141 searchPoint.y=seeds->points[i].y;
142 searchPoint.z=seeds->points[i].z;
143 int neighbor_number=tree.radiusSearch (searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance);
144 if (neighbor_number>0)
146 for (
size_t k=0; k<pointIdxRadiusSearch.size(); ++k)
148 if (!processed_init[pointIdxRadiusSearch[k]])
150 region_indices.push_back(pointIdxRadiusSearch[k]);
151 processed_init[pointIdxRadiusSearch[k]]=
true;
155 pointIdxRadiusSearch.clear();
156 pointRadiusSquaredDistance.clear();
160 queue_list=region_indices;
162 for (
size_t i=0; i<queue_list.size(); ++i)
164 std::vector<float> pointRadiusSquaredDistance;
165 std::vector<int> pointIdxRadiusSearch;
166 searchPoint=cloud->points[queue_list[i]];
167 int neighbor_number=tree.radiusSearch (searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance);
168 if (neighbor_number>min_neighbors)
171 for (
size_t k=0; k<pointIdxRadiusSearch.size(); ++k)
174 if (!processed[pointIdxRadiusSearch[k]])
176 queue_list.push_back(pointIdxRadiusSearch[k]);
177 region_indices.push_back(pointIdxRadiusSearch[k]);
178 processed[pointIdxRadiusSearch[k]]=
true;
182 pointIdxRadiusSearch.clear();
183 pointRadiusSquaredDistance.clear();
187 if(region_indices.size()>0)
188 flags.run_finished=
true;
193 cout <<
"COULD NOT PROCCED REGION GROWING. ERRORS OCCURRED!" <<endl;
void set_input_seeds(typename PointCloud< T1 >::Ptr seeds_in)
Sets the input point cloud seeds.
void process_flags()
Process flags to check if it is ok to run.
PointIndices get_region_point_indices(void)
Provide acces to the result indices.
void set_input_cloud(typename PointCloud< T >::Ptr cloud_in)
Sets the input point cloud data.
vector< int > get_region_indices(void)
Provide acces to the result indices.
void filter()
simply runs the algorithm
Class for pcl region growing algorithm.