Kinect and Robust Plane SAC segmentation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Kinect and Robust Plane SAC segmentation

Hello all;

I am trying to filter planes from a scene obtained with a Kinect sensor. the code to do so is:

pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
pcl::SACSegmentation<PointT> seg;
seg.setOptimizeCoefficients (true);
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations (1000);
seg.setDistanceThreshold (0.01);
pcl::ExtractIndices<PointT> extract;
pcl::PointCloud<PointT>::Ptr cloud_plane (new pcl::PointCloud<PointT>);
pcl::PointCloud<PointT>::Ptr cloud_scene_filtered (new pcl::PointCloud<PointT>);
for(int i=0; i < 2 ; i++)
     seg.setInputCloud (cloud);
     seg.segment (*inliers, *coefficients);
     if (inliers->indices.size () == 0)
                ROS_INFO("Could not estimate a planar model for the given dataset.");
     else ROS_INFO("Plane Model %d Generated",i);
     // Extract the inliers
    extract.setInputCloud (cloud);
    extract.setIndices (inliers);
    extract.setNegative (false);
    extract.filter (*cloud_plane);
    // Create the filtering object
   extract.setNegative (true);
   extract.filter (*cloud_scene_filtered);
   cloud.swap (cloud_scene_filtered);

The problem is that this code, almost always is capable of  estimating planes. Even facing the kinect to the air, with the points it gives, planes are estimated.

How could I make this algorithm more robust to avoid the obtaining of "false planes"?

Thank you all in advance,

Reply | Threaded
Open this post in threaded view

Re: Kinect and Robust Plane SAC segmentation

This post was updated on .

Well you only need 3 points to have a plane model. You could always change your test to something like this:

int min_points_of_plane = 1000;
if (inliers->indices.size () < min_points_of_plane)