Documentation
¶
Overview ¶
Package ransac implements random sample consensus (RANSAC)
Index ¶
- Constants
- Variables
- func ModelFit[R internal.Number, M Model[R]](data [][]R, model M, options ...any) error
- func RandomGonumChooser(N, K uint) iter.Seq[[]int]
- func WithChooser(chooser iter.Seq[[]int]) func(*pNonGenericFields)
- func WithConsensusSetFit(doConsensusSetFit bool) func(*pNonGenericFields)
- func WithMaxIterations(n uint) func(*pNonGenericFields)
- func WithNoMaxIterations() func(*pNonGenericFields)
- func WithNumberOfWorkers(n uint) func(*pNonGenericFields)
- func WithRand(r *rand.Rand) func(*pNonGenericFields)
- func WithTimeout(d time.Duration) func(*pNonGenericFields)
- type Copier
- type CopyableModel
- type Model
Constants ¶
const ( // Termination condition MaxIterations terminationCondition = 1 << iota // Maximum number of iterations TimeLimit )
Variables ¶
var ( ErrNoModelCopier = errors.New("Model does not implement ModelCopier, cannot use multiple workers") ErrMinInliersZero = errors.New("minimum inliers cannot be zero") ErrMinInliers = errors.New("minimum inliers cannot be greater than the number of data points") ErrNumWorkersZero = errors.New("number of workers cannot be zero") ErrMaxIterationsZero = errors.New("max iterations cannot be zero") )
Functions ¶
func RandomGonumChooser ¶
RandomGonumChooser generates random combinations of N choose K using gonum's combin.IndexToCombination function with a random index Note that it may yield the same combination multiple times
func WithChooser ¶
WithChooser sets the chooser function to be used for selecting random subsets of points The chooser function should yield combinations of indices for the points by default this uses the randomGonumChooser function
func WithConsensusSetFit ¶
func WithConsensusSetFit(doConsensusSetFit bool) func(*pNonGenericFields)
WithNoConsensusSetFit enable or disables the consensus set fit typically done after the best model is found. This is enabled by default
func WithMaxIterations ¶
func WithMaxIterations(n uint) func(*pNonGenericFields)
WithMaxIterations limits RANSAC to run only up to n iterations
func WithNoMaxIterations ¶
func WithNoMaxIterations() func(*pNonGenericFields)
WithNoMaxIterations places no iteration limit on RANSAC In practice this means you must specify another termination condition such as WithTimeout
func WithNumberOfWorkers ¶
func WithNumberOfWorkers(n uint) func(*pNonGenericFields)
WithNumberOfWorkers sets the number of goroutines to be used as workers By default this is set to runtime.GOMAXPROCS(0) -- which should be your number of CPUs
func WithRand ¶
WithRand sets the random number generator to be used for selecting random subsets of points This is useful for testing purposes
func WithTimeout ¶
WithMaxIterations limits RANSAC to run only up to duration d
Types ¶
type CopyableModel ¶
CopyableModel represents a Model with a Copy() method. Since this RASNAC implementation modifies the internal state of a Model when it is fitted, each goroutine requires its own distinct model copy
type Model ¶
type Model[R internal.Number] interface { MinimalFitpoints() uint // Minimal number of points needed to fit the model (e.g. 2 for line) Fit([][]R) // Modifies internal state of model IsInlier([]R) bool // Returns true if the point is an inlier }
Model is RANSAC's interface to your model implementation The type parameter R is your number type for your model (typically float64)