Save polygons from concave hull

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Save polygons from concave hull

kokoro
Hi Developers,

I am using PCL concave hull function to get concave hull of a point cloud.
By following the tutorials online, I can only save the points that are on
the concave hull. However, I need the polygons that form the concave hull
(the triangles). I find that there are ways to visualize the polygons, but
no way to output it. Could you please help me with that? The following is my
code. Thanks!



int
 main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr
    cloud (new pcl::PointCloud<pcl::PointXYZ>),
    cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>),
    cloud_projected (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PCDReader reader;
  reader.read ("try.pcd", *cloud);


  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
  pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
  // Create the segmentation object
  pcl::SACSegmentation<pcl::PointXYZ> seg;
  // Optional
  seg.setOptimizeCoefficients (true);
  // Mandatory
  seg.setModelType (pcl::SACMODEL_PLANE);
  seg.setMethodType (pcl::SAC_RANSAC);
  seg.setDistanceThreshold (0.1);

  seg.setInputCloud (cloud);
  seg.segment (*inliers, *coefficients);


  // Create a concave Hull representation of the projected inliers
  pcl::PointCloud<pcl::PointXYZ>::Ptr
    cloud_hull (new pcl::PointCloud<pcl::PointXYZ>);
  std::vector< pcl::Vertices > polygons;  
  pcl::ConcaveHull<pcl::PointXYZ> chull;
  chull.setInputCloud (cloud);
  chull.setAlpha(2);
  chull.setDimension(3);
  chull.reconstruct (*cloud_hull);
  std::cerr << "Concave hull has: " << cloud_hull->points.size () <<
     " data points." << std::endl;

  pcl::PCDWriter writer;
  writer.write ("table_scene_mug_stereo_textured_hull.pcd", *cloud_hull,
  false);

  return (0);
}


Best,
kokoro



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users