All problems
RANSAC Line Inlier Count
Problem
Count RANSAC inliers for a hypothesized line model.
The model is y = slope * x + intercept. Count the 2D points whose vertical residual |y - (slope * x + intercept)| is at most threshold and return the integer count.
Hint
The residual is vertical, so no point-to-line normalization is needed.
Test cases
case 1
in: [[[0,0],[1,1],[2,3],[3,3]],1,0,0.5]
expected: 3
case 2
in: [[[0,0],[1,1],[2,2],[3,3]],1,0,0.001]
expected: 4
case 3
in: [[[0,5],[1,5],[2,5]],1,0,0.5]
expected: 0
case 4
in: [[],1,0,0.5]
expected: 0
Starter codePython
def ransac_line_inliers(points, slope, intercept, threshold):
# Your code here
pass4 test cases · run your code against them in the editor