scikit-image
: 0.19.3
code to reproduce error:
from skimage.measure import LineModelND, ransac
import numpy as np
pts = np.array([[579,298],
[604,276],
[354,241],
[156,240],
[124,157],
[625,105]])
model, inliers = ransac(pts, LineModelND, min_samples=4,residual_threshold=2, max_trials=1000)
error: At least 2 input points needed.
at file skimage/measure/fit.py
line 92
I haven't faced the same error with other points
The RANSAC procedure could not identify 2 or more inliers in the data. The scikit-image implementation does not present a warning in this situation. You can either increase the residual_threshold
or decrease the min_samples
to "fix" this behavior.
Scikit-learn's RANSAC implementation of RANSAC might help you out. Here, the min_samples
and residual_threshold
inputs are optional.
from sklearn.linear_model import RANSACRegressor
X = pts[:,0].reshape(-1,1)
y = pts[:,1].reshape(-1,1))
reg = RANSACRegressor(random_state=None,
min_samples=None,
residual_threshold=None
).fit(X,y)