|
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.");
break;
}
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,
|