当前位置:   article > 正文

ransac算法_pcl库(1)-RANSAC方法滤除地面

python pcd文件ransac去地面 csdn

fa6cf45d86332a0d245775a3537264ba.png

RANSAC (Random sample consensus) 随机抽样一致法算法:

1:Select randomly the minimum number of points required to determine the model parameters.

2:Solve for the parameters of the model.

3:Determine how many points from the set of all points fit with a predefined tolerance

.

4:If the fraction of the number of inliers over the total number points in the set exceeds a predefined threshold

, re-estimate the model parameters using all the identified inliers and terminate.

5:Otherwise, repeat steps 1 through 4 (maximum of N times)

伪代码

  1. Given:
  2. data - a set of observed data points(这里指点云数据)
  3. model - a model that can be fitted to data points(这里指平面模型)
  4. n - the minimum number of data values required to fit the model
  5. (n - 满足模型的最少数据个数)
  6. k - the maximum number of iterations allowed in the algorithm(最多迭代次数)
  7. t - a threshold value for determining when a data point fits a model
  8. (t - 点是否适用于模型的阈值,这里指的是点到平面的距离)
  9. d - the number of close data values required to assert that a model fits well to data
  10. ( (d - 判定模型是否适用于数据集的数据数目)
  11. Return:
  12. bestfit - model parameters which best fit the data (or nil if no good model is found)
  13. iterations = 0
  14. bestfit = nil
  15. besterr = something really large
  16. while iterations < k {
  17. maybeinliers = n randomly selected values from data
  18. maybemodel = model parameters fitted to maybeinliers
  19. alsoinliers = empty set
  20. for every point in data not in maybeinliers {
  21. if point fits maybemodel with an error smaller than t
  22. add point to alsoinliers
  23. }
  24. if the number of elements in alsoinliers is > d {
  25. % this implies that we may have found a good model
  26. % now test how good it is
  27. bettermodel = model parameters fitted to all points in maybeinliers and alsoinliers
  28. thiserr = a measure of how well model fits these points
  29. if thiserr < besterr {
  30. bestfit = bettermodel
  31. besterr = thiserr
  32. }
  33. }
  34. increment iterations
  35. }
  36. return bestfit

代码链接:

Qjizhi/ground_filter_pcl_RANSAC

滤除底面前后对比图(这里使用了kitti的数据作为例子):

eb3f7ed1e4b5d675c50ff16c4fd5bdd2.png

由于地面不是倾角为零的平面,可以看到还是有些地面点的,所以设置距离阈值参数的时候需要试试,这里设为0.2比较好(测试下来效果不错),源码设为0.15就不改了.

        seg.setDistanceThreshold(0.2);

参考:

M.A. Fischler and R.C. Bolles. Random sample consensus: A paradigm for modelfitting with applications to image analysis and automated cartography.Commu-nications of the ACM, 24(6):381–395, 1981.

RANSAC - formulasearchengine

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号