c++3dgeometrypoint-cloud-librarypoint-clouds

PCL::RegionGrowing on negative Indices


I have a pointcloud from which I extracted a ground plane. Now I want to apply a region growing on all points except for the ground plane. How could I do that efficiently ?

pcl::SACSegmentationFromNormals <pcl::PointXYZRGB, pcl::Normal> ground_seg;
ground_seg.setInputCloud(input_cloud);
ground_seg.setInputNormals(input_normals);
ground_seg.segment(*ground_indices, *coefficients);

pcl::RegionGrowing<pcl::PointXYZRGB, pcl::Normal> region_growing;
region_growing.setIndices(ground_indices); // In this case, region growing is applied on the plane indices

Solution

  • I couldn't just find a way to get the negative indices of what SACSegmentationFromNormals find, but you could try use:

    pcl::ExtractIndices, see this tutorial: https://pcl.readthedocs.io/en/latest/extract_indices.html?highlight

    Then use setNegative(true) to get a new point cloud, only containing what you want to do region growing on afterwards.