参考文档:
//http://docs.pointclouds.org/1.9.1/classpcl_1_1_sample_consensus_model_circle3_d.html
//使用PCL绘制空间圆
//https://blog.csdn.net/zyj8691/article/details/79416733
//http://www.pcl-users.org/RANSAC-Model-Coefficients-td4041435.html
//http://www.pcl-users.org/SOLVED-Terrible-circle-fitting-results-with-SampleConsensusModelCircle3D-td4043214.html
//http://docs.pointclouds.org/1.9.1/group__sample__consensus.html
//[center.x, center.y, center.z, radius, normal.x, normal.y, normal.z]
//http://pointclouds.org/documentation/tutorials/random_sample_consensus.php#random-sample-consensus
pcl::PointCloud<pcl::PointXYZ>::Ptr final (new pcl::PointCloud<pcl::PointXYZ>);
std::vector<int> inliersCircle3D;
pcl::SampleConsensusModelCircle3D<PointT>::Ptr socCircle3D ( new pcl::SampleConsensusModelCircle3D<PointT> (oriCloud_inliers) );
pcl::RandomSampleConsensus<PointT>::Ptr ransac ( new pcl::RandomSampleConsensus<PointT> (socCircle3D) );
ransac->setDistanceThreshold(0.1f);
ransac->computeModel();
ransac->getInliers(inliersCircle3D);
Eigen::VectorXf circle_coeff;
ransac->getModelCoefficients(circle_coeff);
PointCloud::Ptr finalCircle3D(new PointCloud);
pcl::copyPointCloud (*oriCloud_inliers, inliersCircle3D, *finalCircle3D);
std::cout<<"circle_coeff "<<"rows="<<circle_coeff.rows()<<"cols="<<circle_coeff.cols()<<"coefficeints="<<circle_coeff.size()<<std::endl;
circle_coeff rows=7cols=1coefficeints=7
#ifdef DEBUG_VIEW_CIRCLE3D
pcl::visualization::PointCloudColorHandlerCustom<PointT> color_handler5(finalCircle3D, 230, 50, 12);//红色
view->addPointCloud(finalCircle3D, color_handler5, "CH5");
pcl::ModelCoefficients sphere_coeff3;
sphere_coeff3.values.resize (4);
sphere_coeff3.values[0] = circle_coeff(0, 0);
sphere_coeff3.values[1] = circle_coeff(1, 0);
sphere_coeff3.values[2] = circle_coeff(2, 0);
sphere_coeff3.values[3] = circle_coeff(3, 0);//半径
view->addSphere(sphere_coeff3, "sphere3");
#endif