使用PCL提取平面的方式

本文介绍了使用PCL库进行平面提取的几种方法,包括基于RANSAC的循环提取和平面生长法。详细探讨了RANSAC算法,并通过示例展示了提取效果。
摘要由CSDN通过智能技术生成

本文主要总结了几种提取平面的方式,算法的原理就不细说了.

1.RANSAC

循环提取平面,直到小于20个点.

void groundRemoval(pcl::PointCloud<pcl::PointXYZ>::Ptr in,int& pl_num)
{

    pcl::PointCloud<pcl::PointXYZ>::Ptr in_totle(new pcl::PointCloud<pcl::PointXYZ>);
    *in_totle = *in;

    int totle_in_size = in_totle->points.size();
    pl_num = 0;
    std::vector<std::vector<double> > pl_nor_tot;
    while (in_totle->points.size() > 20)
    {
        pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
        pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
        pcl::PointCloud<pcl::PointXYZ>::Ptr outgr_cloud(new pcl::PointCloud<pcl::PointXYZ>);
        pcl::PointCloud<pcl::PointXYZ>::Ptr ingr_cloud(new pcl::PointCloud<pcl::PointXYZ>);

        doRansacPlane(in_totle, inliers, coefficients,0.015);//plane

        ingr_cloud = filterCloud(in_totle, inliers, false);//plane points
        outgr_cloud = filterCloud(in_totle, inliers, true);
        *in_totle = *outgr_cloud;
        if(ingr_cloud->points.size() < 200)
        {
            //cout<<"ingr_cloud size is small,continue"<<endl;
            continue;
        }

        //attribute:normals not used
        double A = coefficients->values[0];
        double B = coefficients->values[1];
        double C = coefficients->values[2];
        double D = coefficients->values[3];

        double Aunit = A / sqrt(A*A+B*B+C*C);
        double Bunit = B / sqrt(A*A+B*B+C*C);
      
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值