gpt4 book ai didi

c++ - 如何在RANSAC平面估算器上包含自定义约束/等级?

转载 作者:行者123 更新时间:2023-12-01 14:58:45 28 4
gpt4 key购买 nike

我正在尝试使用点云库从点云中分割一个平面,并且我有一些有关平面模型的先验信息(即法线应该类似于z轴,高度(d)应该大约为0) 。

有没有办法强制我的RANSAC算法选择与我先前模型相似的系数?我认为可以通过在模型中加入约束或修改所选飞机的排名来实现。

我尝试使用PassThrough过滤器过滤数据,该过滤器仅保留围绕先前平面的点。然后,我使用SACSegmentation对象在过滤后的数据上找到具有法线平面模型和法线 Angular 公差的平面。

我也尝试使用平行平面模型。


pcl::PointIndices::Ptr indices_for_segmentation(new pcl::PointIndices);
pcl::PassThrough<pcl::PointXYZL> pass_through;
pass_through.setInputCloud(cloud_);
pass_through.setIndices(clean_indices);
pass_through.setFilterFieldName("z");
pass_through.setFilterLimits(z_min_lim, z_max_lim);
pass_through.filter(indices_for_segmentation->indices);


pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
pcl::SACSegmentation<pcl::PointXYZL> ransac;
ransac.setOptimizeCoefficients(true);
ransac.setIndices(indices_for_segmentation);
ransac.setModelType(pcl::SACMODEL_PERPENDICULAR_PLANE);
ransac.setMethodType(pcl::SAC_RANSAC);
ransac.setDistanceThreshold(plane_thresh);
ransac.setInputCloud(cloud_);
ransac.setAxis(Eigen::Vector3f(0, 0, 1)); // search around the z axis
ransac.setEpsAngle(pcl::deg2rad(5));
ransac.segment(*inliers, *coefficients_);

当前解决方案的问题在于
  • 在两种情况下(平行平面和法向平面),该算法似乎都没有严格地使用epsAngle约束(似乎在某种程度上被建议使用)
  • 这不会满足飞机高度的要求。
  • 穿过过滤器有时仅留下几个点,这使得平面估计不稳定(每帧估计一个不同的平面)
  • 最佳答案

    在我看来,您对如何使用PCL有一些误解。

    您正在使用pcl::SACSegmentation<pcl::PointXYZL>声明RANSAC估计量。

    如果仅提供XYZ数据,您认为RANSAC如何计算点法线和表面法线之间的 Angular 差?正确,它不能

    因此,首先,您必须为输入云计算法线。有关更多信息,请参见此tutorial

    一旦有了法线,您只需要对现有代码进行少量更改。

    pcl::PointIndices::Ptr inliers(new pcl::PointIndices);

    pcl::SACSegmentationFromNormals<pcl::PointXYZL, pcl::Normal> ransac; // ** change to SACSegmentationFromNormals
    ransac.setOptimizeCoefficients(true);
    ransac.setIndices(indices_for_segmentation);
    ransac.setModelType(pcl::SACMODEL_NORMAL_PLANE);
    ransac.setMethodType(pcl::SAC_RANSAC);
    ransac.setDistanceThreshold(plane_thresh);
    ransac.setInputCloud(cloud_);
    ransac.setInputNormals(normals_); // ** set input normals
    ransac.setAxis(Eigen::Vector3f(0, 0, 1)); // search around the z axis
    ransac.setEpsAngle(pcl::deg2rad(5));
    ransac.segment(*inliers, *coefficients_);

    希望这有帮助,祝你好运!

    关于c++ - 如何在RANSAC平面估算器上包含自定义约束/等级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57059047/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com