Reference¶
RANSAC¶
- class pyransac.ransac.RansacParams(samples: int, iterations: int, confidence: float, threshold: float, replacement: bool)¶
Random sample consensus (RANSAC) function parameters.
This class contains the parameters for the RANSAC algorithm.
- confidence: float¶
The RANSAC confidence value (0 <= confidence <= 1).
- iterations: int¶
Maximum number iterations to complete.
- replacement: bool¶
The samples should be drawn with replacement (i.e. repeats are OK)
- samples: int¶
The number of random samples to take per iteration.
- threshold: float¶
The error threshold to consider a point an inlier
- pyransac.ransac.find_inliers(points: List, model: Model, params: RansacParams)¶
Find the inliers from a data set.
Finds the inliers from a given data set given a model and an error function.
- Parameters
points – data points to evaluate
model – type of model to which the data should adhere
params – parameters for the RANSAC algorithm
- Returns
inliers
Data Models¶
- class pyransac.base.Model¶
ABC class for data models.
Derivative classes should extend this class and implement its interface.
- abstract calc_error(point) float ¶
Calculates error between data point and model.
- Parameters
point – data point to test against
- abstract make_model(points: List) None ¶
Makes a model from given data points.
- Parameters
points – list of data points with which to make model
- class pyransac.line2d.Line2D(slope=None, y_int=None, x_int=None)¶
Model for a 2-dimensional line.
- calc_error(point: Point2D) float ¶
Calculate error between data point and 2D model.
- Parameters
point – data point to calculate error with
- Returns
calculated error
- make_model(points: List[Point2D]) None ¶
Makes equation for 2D line given two data points.
Model parameters are stored internally.
- Parameters
points – list of data points to make model (length must be 2)
- Returns
None
- property slope¶
Gets the slope of the model.
- Returns
slope of line (None if model not made).
- property x_int¶
Gets the x intercept of the model.
- Returns
x intercept of line (None if model not made).
- property y_int¶
Gets the y intercept of the model.
- Returns
y intercept of line (None if model not made).