30 input_cloud_ptr.reset(
new pcl::PointCloud<PointT>);
31 output_colored_cloud.reset(
new pcl::PointCloud<PointT>);
32 output_labeled_cloud.reset(
new pcl::PointCloud<PointL>);
34 SmoothnessThreshold = 30.0f;
35 CurvatureThreshold = 10.0f;
42 pcl::copyPointCloud(*CloudPtr, *input_cloud_ptr);
44 RegionGrowingSegmenter();
46 return output_colored_cloud;
50 void RGSegClass::RegionGrowingSegmenter()
52 pcl::search::Search<PointT>::Ptr tree = pcl::search::Search<PointT>::Ptr(
new pcl::search::KdTree<PointT>);
53 pcl::PointCloud <pcl::Normal>::Ptr normals(
new pcl::PointCloud <pcl::Normal>);
54 pcl::NormalEstimation<PointT, pcl::Normal> normal_estimator;
55 normal_estimator.setSearchMethod(tree);
56 normal_estimator.setInputCloud(input_cloud_ptr);
57 normal_estimator.setKSearch(50);
58 normal_estimator.compute(*normals);
69 pcl::RegionGrowing<PointT, pcl::Normal> reg;
70 reg.setMinClusterSize(50);
71 reg.setMaxClusterSize(1000000);
72 reg.setSearchMethod(tree);
73 reg.setNumberOfNeighbours(25);
74 reg.setInputCloud(input_cloud_ptr);
76 reg.setInputNormals(normals);
77 reg.setSmoothnessThreshold(SmoothnessThreshold / 180.0 *
M_PI);
78 reg.setCurvatureThreshold(CurvatureThreshold);
80 std::vector <pcl::PointIndices> clusters;
81 reg.extract(clusters);
83 std::cout <<
"=RG Segmenter: Number of clusters is " << clusters.size() << std::endl;
85 output_colored_cloud = reg.getColoredCloudRGBA();
92 SmoothnessThreshold = SmoothnessThres;
93 CurvatureThreshold = CurvatureThres;
95 std::cout <<
"=RG Segmenter: Parameters updated! >> SmoothnessThreshold : " << SmoothnessThreshold <<
" CurvatureThreshold: " << CurvatureThreshold << std::endl;
99 void RGSegClass::ConvertFromXYZRGBAtoXYZL()