31 input_cloud_ptr.reset(
new pcl::PointCloud<PointT>);
32 input_normals_ptr.reset(
new pcl::PointCloud<pcl::Normal>);
34 sv_labeled_cloud.reset(
new pcl::PointCloud<pcl::PointXYZL>);
35 lccp_labeled_cloud.reset(
new pcl::PointCloud<pcl::PointXYZL>);
41 voxel_resolution = 0.0095f;
42 seed_resolution = 0.06f;
43 color_importance = 0.0f;
44 spatial_importance = 1.0f;
45 normal_importance = 4.0f;
46 use_single_cam_transform =
false;
47 use_supervoxel_refinement =
false;
50 concavity_tolerance_threshold = 10;
51 smoothness_threshold = 0.1;
52 min_segment_size = 10;
53 use_extended_convexity =
false;
54 use_sanity_criterion =
false;
58 normals_scale = seed_resolution / 2.0;
63 if (use_extended_convexity)
80 pcl::copyPointCloud(*CloudPtr, *input_cloud_ptr);
84 return lccp_labeled_cloud;
88 bool LCCPSegClass::SegmentPointCloud()
93 pcl::SupervoxelClustering<PointT> super(voxel_resolution, seed_resolution);
94 super.setUseSingleCameraTransform(use_single_cam_transform);
96 super.setInputCloud(input_cloud_ptr);
100 super.setNormalCloud(input_normals_ptr);
103 super.setColorImportance(color_importance);
104 super.setSpatialImportance(spatial_importance);
105 super.setNormalImportance(normal_importance);
106 supervoxel_clusters.clear();
109 super.extract(supervoxel_clusters);
111 if (supervoxel_clusters.size() == 0)
118 if (use_supervoxel_refinement)
121 super.refineSupervoxels(2, supervoxel_clusters);
127 std::multimap<uint32_t, uint32_t> supervoxel_adjacency;
128 super.getSupervoxelAdjacency(supervoxel_adjacency);
131 pcl::PointCloud<pcl::PointNormal>::Ptr sv_centroid_normal_cloud = pcl::SupervoxelClustering<PointT>::makeSupervoxelNormalCloud(supervoxel_clusters);
136 pcl::LCCPSegmentation<PointT> lccp;
137 lccp.setConcavityToleranceThreshold(concavity_tolerance_threshold);
138 lccp.setSanityCheck(use_sanity_criterion);
139 lccp.setSmoothnessCheck(
true, voxel_resolution, seed_resolution, smoothness_threshold);
140 lccp.setKFactor(k_factor);
144 if (min_segment_size > 0)
147 lccp.setMinSegmentSize(min_segment_size);
152 lccp.setInputSupervoxels(supervoxel_clusters, supervoxel_adjacency);
157 sv_labeled_cloud = super.getLabeledCloud();
158 lccp_labeled_cloud = sv_labeled_cloud->makeShared();
159 lccp.relabelCloud(*lccp_labeled_cloud);
160 SuperVoxelAdjacencyList sv_adjacency_list;
161 lccp.getSVAdjacencyList(sv_adjacency_list);
170 void LCCPSegClass::UpdateParameters(
float voxelRes,
float seedRes,
float colorImp,
float spatialImp,
float normalImp,
float concavityThres,
float smoothnessThes, uint32_t minSegSize)
172 voxel_resolution = voxelRes;
173 seed_resolution = seedRes;
174 color_importance = colorImp;
175 spatial_importance = spatialImp;
176 normal_importance = normalImp;
177 concavity_tolerance_threshold = concavityThres;
178 smoothness_threshold = smoothnessThes;
179 min_segment_size = minSegSize;