Skip to content

Instantly share code, notes, and snippets.

@suplo
Created August 7, 2013 07:46
Show Gist options
  • Save suplo/6172050 to your computer and use it in GitHub Desktop.
Save suplo/6172050 to your computer and use it in GitHub Desktop.
Object segmentation PCL
// Segment planes
pcl::OrganizedMultiPlaneSegmentation< PointT, pcl::Normal, pcl::Label > mps;
mps.setMinInliers (10000);
mps.setAngularThreshold (0.017453 * 2.0); // 2 degrees
mps.setDistanceThreshold (0.02); // 2cm
mps.setInputNormals (normal_cloud);
mps.setInputCloud (cloud);
std::vector< pcl::PlanarRegion< PointT > > regions;
mps.segmentAndRefine (regions);
for (size_t i = 0; i < regions.size (); i++)
{
Eigen::Vector3f centroid = regions[i].getCentroid ();
Eigen::Vector4f model = regions[i].getCoefficients ();
pcl::PointCloud boundary_cloud;
boundary_cloud.points = regions[i].getContour ();
printf ("Centroid: (%f, %f, %f)\n Coefficients: (%f, %f, %f, %f)\n Inliers: %d\n",
centroid[0], centroid[1], centroid[2],
model[0], model[1], model[2], model[3],
boundary_cloud.points.size ());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment