I'm trying to detect the floor Plane with my Kinect via PCL. My ASUS Xtion Pro Live is mounted stationary and is not moved during the process. The Floor is the dominating plane in the scene.
void ToolKit::getGroundPlane(ntk::RGBDImage& image){
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
rgbdImageToPointCloud(*cloud, image, true /* keep dense */);
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
pcl::SACSegmentation<pcl::PointXYZ> seg;
seg.setOptimizeCoefficients(true);
seg.setModelType(pcl::SACMODEL_PLANE);
seg.setMethodType(pcl::SAC_RANSAC);
seg.setDistanceThreshold(0.05);
seg.setInputCloud(cloud->makeShared());
seg.segment (*inliers, *coefficients);
if (inliers->indices.size() == 0){
PCL_ERROR ("Could not estimate a planar model for the given dataset.");
}
setGroundPlane(ntk::Plane(coefficients->values[0],coefficients->values[1],coefficients->values[2],coefficients->values[3]));
std::cout << m_ground_plane.a << "," << m_ground_plane.b << "," << m_ground_plane.c << "," << m_ground_plane.d << "\n";
setGroundIndices(inliers->indices);
}