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;
40 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr&
44 pcl::copyPointCloud(*CloudPtr, *input_cloud_ptr);
46 RegionGrowingSegmenter();
48 return output_colored_cloud;
54 RGSegClass::RegionGrowingSegmenter()
56 pcl::search::Search<PointT>::Ptr tree =
57 pcl::search::Search<PointT>::Ptr(
new pcl::search::KdTree<PointT>);
58 pcl::PointCloud<pcl::Normal>::Ptr normals(
new pcl::PointCloud<pcl::Normal>);
59 pcl::NormalEstimation<PointT, pcl::Normal> normal_estimator;
60 normal_estimator.setSearchMethod(tree);
61 normal_estimator.setInputCloud(input_cloud_ptr);
62 normal_estimator.setKSearch(50);
63 normal_estimator.compute(*normals);
74 pcl::RegionGrowing<PointT, pcl::Normal> reg;
75 reg.setMinClusterSize(50);
76 reg.setMaxClusterSize(1000000);
77 reg.setSearchMethod(tree);
78 reg.setNumberOfNeighbours(25);
79 reg.setInputCloud(input_cloud_ptr);
81 reg.setInputNormals(normals);
82 reg.setSmoothnessThreshold(SmoothnessThreshold / 180.0 *
M_PI);
83 reg.setCurvatureThreshold(CurvatureThreshold);
85 std::vector<pcl::PointIndices> clusters;
86 reg.extract(clusters);
88 std::cout <<
"=RG Segmenter: Number of clusters is " << clusters.size() << std::endl;
90 output_colored_cloud = reg.getColoredCloudRGBA();
98 SmoothnessThreshold = SmoothnessThres;
99 CurvatureThreshold = CurvatureThres;
101 std::cout <<
"=RG Segmenter: Parameters updated! >> SmoothnessThreshold : "
102 << SmoothnessThreshold <<
" CurvatureThreshold: " << CurvatureThreshold << std::endl;
108 RGSegClass::ConvertFromXYZRGBAtoXYZL()