|
大家好,我在利用pcl::SACSegmentationFromNormals<pcl::PointXYZ, pcl::Normal> Segmentation;进行平面分割时遇到了这样的问题,见附件的图。代码粘贴如下:
pcl::PointCloud<pcl::PointXYZ>::Ptr PlaneSegmentationCloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::SACSegmentationFromNormals<pcl::PointXYZ, pcl::Normal> Segmentation;
pcl::ModelCoefficients::Ptr coefficients_plane (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers_plane (new pcl::PointIndices);
Segmentation.setOptimizeCoefficients (true);
Segmentation.setModelType (pcl::SACMODEL_NORMAL_PARALLEL_PLANE);
Segmentation.setNormalDistanceWeight (0.1);//法向量约束
Segmentation.setMethodType (pcl::SAC_RANSAC);
Segmentation.setMaxIterations (200);
Segmentation.setDistanceThreshold (0.1);
const Eigen::Vector3f ax = Eigen::Vector3f(0,0,1);
Segmentation.setAxis(ax);
Segmentation.setEpsAngle(0.26);//轴向约束
pcl::SACSegmentation<pcl::PointXYZ>::SearchPtr searcher (new pcl::search::KdTree<pcl::PointXYZ>) ;
Segmentation.setSamplesMaxDist(1.0, searcher);//采样点间隔约束
Segmentation.setInputCloud(cloud->makeShared());
Segmentation.setInputNormals (cloud_normals->makeShared());
searcher->setInputCloud(cloud->makeShared());
Segmentation.segment(*inliers_plane,*coefficients_plane);
求大师指点。
|
|