Skip to main content
. 2025 May 22;25(11):3268. doi: 10.3390/s25113268
Algorithm 2 Improved slope-constrained RANSAC algorithm with early termination
Require: Current frame laser stripe point set P, previous slope mprev,
    1:            max iterations K, distance threshold τ,
    2:            slope tolerance δ, consecutive patience N
Ensure: Optimal line model (a*,b*), inlier set I*
    3: Initialize best inliers: I*
    4: Initialize optimal model: (a*,b*)(0,0)
    5: Iteration counter: k0
    6: No improvement counter: no_improve0
    7: while  k<K  and  no_improve<N   do
    8:     kk+1
    9:     repeat
    10:            Randomly select two distinct points p1(x1,y1),p2(x2,y2)P
    11:            Compute slope: mcurry2y1x2x1+ϵ
    12:     until |mcurrmprev|<δ
    13:     Construct line model: amcurr,by1ax1
    14:     Temporary inlier set: I
    15:     for each point p(x,y)P do
    16:            Distance: d|axy+b|a2+1
    17:            if d<τ then
    18:                II{p}
    19:            end if
    20:     end for
    21:     if |I|>|I*| then
    22:           I*I
    23:            (a*,b*)(a,b)
    24:            no_improve0
    25:     else
    26:            no_improveno_improve+1
    27:     end if
    28: end while
    29: return (a*,b*),I*