Package com.irurueta.geometry.estimators
Class DualConicRobustEstimator
java.lang.Object
com.irurueta.geometry.estimators.DualConicRobustEstimator
- Direct Known Subclasses:
LMedSDualConicRobustEstimator,MSACDualConicRobustEstimator,PROMedSDualConicRobustEstimator,PROSACDualConicRobustEstimator,RANSACDualConicRobustEstimator
This is an abstract class for algorithms to robustly find the best dual conic
that fits in a collection of 2D lines.
Implementations of this class should be able to detect and discard outliers
in order to find the best solution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleAmount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).static final doubleConstant defining default confidence of the estimated result, which is 99%.static final intDefault maximum allowed number of iterations.static final floatDefault amount of progress variation before notifying a change in estimation progress.static final com.irurueta.numerical.robust.RobustEstimatorMethodDefault robust estimator method when none is provided.List of lines to be used to estimate a dual conic.protected DualConicRobustEstimatorListenerListener to be notified of events such as when estimation starts, ends or its progress significantly changes.protected booleanIndicates if this estimator is locked because an estimation is being computed.static final doubleMaximum allowed confidence value.static final floatMaximum allowed value for progress delta.protected intMaximum allowed number of iterations.static final doubleMinimum allowed confidence value.static final intMinimum allowed number of iterations.static final floatMinimum allowed value for progress delta.static final intMinimum number of 2D lines required to estimate a Dual Conic.protected floatAmount of progress variation before notifying a progress change during estimation.private com.irurueta.algebra.MatrixMatrix representation of a dual conic to be reused when computing residuals.private com.irurueta.algebra.MatrixMatrix representation of a 2D line to be reused when computing residuals. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.protectedConstructor.protectedDualConicRobustEstimator(DualConicRobustEstimatorListener listener, List<Line2D> lines) Constructor.protectedDualConicRobustEstimator(List<Line2D> lines) Constructor with lines. -
Method Summary
Modifier and TypeMethodDescriptionstatic DualConicRobustEstimatorcreate()Creates a dual conic robust estimator based on 2D line samples and using default robust estimator method.static DualConicRobustEstimatorcreate(double[] qualityScores) Creates a dual conic robust estimator based on 2D line samples and using default robust estimator method.static DualConicRobustEstimatorcreate(double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided robust estimator method.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener) Creates a dual conic robust estimator based on 2D line samples and using provided listener and default robust estimator method.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, double[] qualityScores) Creates a dual conic robust estimator based on 2D line samples and using provided listener and default estimator method.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, List<Line2D> lines) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines and default robust estimator method.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, List<Line2D> lines, double[] qualityScores) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines and default estimator method.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines.static DualConicRobustEstimatorcreate(DualConicRobustEstimatorListener listener, List<Line2D> lines, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines.static DualConicRobustEstimatorcreate(com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided robust estimator method.static DualConicRobustEstimatorCreates a dual conic robust estimator based on 2D line samples and using provided lines and default robust estimator method.static DualConicRobustEstimatorCreates a dual conic robust estimator based on 2D line samples and using provided lines and default estimator method.static DualConicRobustEstimatorcreate(List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator method based on 2D line samples and using provided lines and robust estimator method.static DualConicRobustEstimatorCreates a dual conic robust estimator based on 2D line samples and using provided lines and robust estimator method.abstract DualConicestimate()Estimates a dual conic using a robust estimator and the best set of 2D lines that fit into the locus of the estimated dual conic found using the robust estimator.doubleReturns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).getLines()Returns list of lines to be used to estimate a dual conic.Returns reference to listener to be notified of events such as when estimation starts, ends or its progress significantly changes.intReturns maximum allowed number of iterations.abstract com.irurueta.numerical.robust.RobustEstimatorMethodReturns method being used for robust estimation.floatReturns amount of progress variation before notifying a progress change during estimation.double[]Returns quality scores corresponding to each line.private voidinternalSetLines(List<Line2D> lines) Internal method to set list of lines to be used to estimate a dual conic.booleanIndicates whether listener has been provided and is available for retrieval.booleanisLocked()Indicates if this instance is locked because estimation is being computedbooleanisReady()Indicates if estimator is ready to start the dual conic estimation.protected doubleComputes the residual between a dual conic and a 2D line.voidsetConfidence(double confidence) Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).voidSets list of lines to be used to estimate a dual conic.voidsetListener(DualConicRobustEstimatorListener listener) Sets listener to be notified of events such as when estimation starts, ends or its progress significantly changes.voidsetMaxIterations(int maxIterations) Sets maximum allowed number of iterations.voidsetProgressDelta(float progressDelta) Sets amount of progress variation before notifying a progress change during estimation.voidsetQualityScores(double[] qualityScores) Sets quality scores corresponding to each line.
-
Field Details
-
MINIMUM_SIZE
public static final int MINIMUM_SIZEMinimum number of 2D lines required to estimate a Dual Conic.- See Also:
-
DEFAULT_PROGRESS_DELTA
public static final float DEFAULT_PROGRESS_DELTADefault amount of progress variation before notifying a change in estimation progress. By default, this is set to 5%.- See Also:
-
MIN_PROGRESS_DELTA
public static final float MIN_PROGRESS_DELTAMinimum allowed value for progress delta.- See Also:
-
MAX_PROGRESS_DELTA
public static final float MAX_PROGRESS_DELTAMaximum allowed value for progress delta.- See Also:
-
DEFAULT_CONFIDENCE
public static final double DEFAULT_CONFIDENCEConstant defining default confidence of the estimated result, which is 99%. This means that with a probability of 99% estimation will be accurate because chosen sub-samples will be inliers.- See Also:
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONSDefault maximum allowed number of iterations.- See Also:
-
MIN_CONFIDENCE
public static final double MIN_CONFIDENCEMinimum allowed confidence value.- See Also:
-
MAX_CONFIDENCE
public static final double MAX_CONFIDENCEMaximum allowed confidence value.- See Also:
-
MIN_ITERATIONS
public static final int MIN_ITERATIONSMinimum allowed number of iterations.- See Also:
-
DEFAULT_ROBUST_METHOD
public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHODDefault robust estimator method when none is provided. -
listener
Listener to be notified of events such as when estimation starts, ends or its progress significantly changes. -
locked
protected volatile boolean lockedIndicates if this estimator is locked because an estimation is being computed. -
progressDelta
protected float progressDeltaAmount of progress variation before notifying a progress change during estimation. -
confidence
protected double confidenceAmount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0. -
maxIterations
protected int maxIterationsMaximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval. -
lines
List of lines to be used to estimate a dual conic. Provided list must have a size greater or equal than MINIMUM_SIZE. -
testLine
private com.irurueta.algebra.Matrix testLineMatrix representation of a 2D line to be reused when computing residuals. -
testDualC
private com.irurueta.algebra.Matrix testDualCMatrix representation of a dual conic to be reused when computing residuals.
-
-
Constructor Details
-
DualConicRobustEstimator
protected DualConicRobustEstimator()Constructor. -
DualConicRobustEstimator
Constructor.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
-
DualConicRobustEstimator
Constructor with lines.- Parameters:
lines- 2D lines to estimate a dual conic.- Throws:
IllegalArgumentException- if provided list of lines don't have a size greater or equal than MINIMUM_SIZE.
-
DualConicRobustEstimator
Constructor.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.lines- 2D lines to estimate a dual conic.- Throws:
IllegalArgumentException- if provided list of lines don't have a size greater or equal than MINIMUM_SIZE.
-
-
Method Details
-
getListener
Returns reference to listener to be notified of events such as when estimation starts, ends or its progress significantly changes.- Returns:
- listener to be notified of events.
-
setListener
Sets listener to be notified of events such as when estimation starts, ends or its progress significantly changes.- Parameters:
listener- listener to be notified of events.- Throws:
LockedException- if robust estimator is locked.
-
isListenerAvailable
public boolean isListenerAvailable()Indicates whether listener has been provided and is available for retrieval.- Returns:
- true if available, false otherwise.
-
isLocked
public boolean isLocked()Indicates if this instance is locked because estimation is being computed- Returns:
- true if locked, false otherwise.
-
getProgressDelta
public float getProgressDelta()Returns amount of progress variation before notifying a progress change during estimation.- Returns:
- amount of progress variation before notifying a progress change during estimation.
-
setProgressDelta
Sets amount of progress variation before notifying a progress change during estimation.- Parameters:
progressDelta- amount of progress variation before notifying a progress change during estimation.- Throws:
IllegalArgumentException- if progress delta is less than zero or greater than 1.LockedException- if this estimator is locked because an estimation is being computed.
-
getConfidence
public double getConfidence()Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates that probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Returns:
- amount of confidence as a value between 0.0 and 1.0.
-
setConfidence
Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0- Parameters:
confidence- confidence to be set as a value between 0.0 and 1.0.- Throws:
IllegalArgumentException- if provided value is not between 0.0 and 1.0.LockedException- if this estimator is locked because an estimator is being computed.
-
getMaxIterations
public int getMaxIterations()Returns maximum allowed number of iterations. If maximum allowed number of iterations is achieved without converging to a result when calling estimate(), a RobustEstimatorException will be raised.- Returns:
- maximum allowed number of iterations.
-
setMaxIterations
Sets maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.- Parameters:
maxIterations- maximum allowed number of iterations to be set.- Throws:
IllegalArgumentException- if provided value is less than 1.LockedException- if this estimator is locked because an estimation is being computed.
-
getLines
Returns list of lines to be used to estimate a dual conic. Provided list have a size greater or equal than MINIMUM_SIZE.- Returns:
- list of lines to be used to estimate a dual conic.
-
setLines
Sets list of lines to be used to estimate a dual conic. Provided list must have a size greater or equal than MINIMUM_SIZE.- Parameters:
lines- list of lines to be used to estimate a dual conic.- Throws:
IllegalArgumentException- if provided list of lines doesn't have a size greater or equal than MINIMUM_SIZE.LockedException- if estimator is locked because a computation is already in progress.
-
isReady
public boolean isReady()Indicates if estimator is ready to start the dual conic estimation. This is true when MINIMUM_SIZE lines are available.- Returns:
- true if estimator is ready, false otherwise.
-
getQualityScores
public double[] getQualityScores()Returns quality scores corresponding to each line. The larger the score value the better the quality of the line measure. This implementation always return null. Subclasses using quality scores must implement proper behaviour.- Returns:
- quality scores corresponding to each line.
-
setQualityScores
Sets quality scores corresponding to each line. The larger the score value the better the quality of the matching. This implementation makes no action. Subclasses using quality scores must implement proper behaviour.- Parameters:
qualityScores- quality scores corresponding to each line.- Throws:
LockedException- if robust estimator is locked because an estimation is already in progress.IllegalArgumentException- if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 9 samples).
-
create
public static DualConicRobustEstimator create(com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided robust estimator method.- Parameters:
method- method of a robust estimator algorithm to estimate bes dual conic.- Returns:
- an instance of a dual conic robust estimator.
-
create
public static DualConicRobustEstimator create(List<Line2D> lines, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided lines and robust estimator method.- Parameters:
lines- 2D lines to estimate a dual conic.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have a size greater or equal than MINIMUM_SIZE.
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, List<Line2D> lines, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.lines- 2D lines to estimate a dual conic.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have a size greater or equal than MINIMUM_SIZE.
-
create
public static DualConicRobustEstimator create(double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided robust estimator method.- Parameters:
qualityScores- quality scores corresponding to each provided line.method- method of a robust estimator algorithm to estimate bes dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 5 lines).
-
create
public static DualConicRobustEstimator create(List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator method based on 2D line samples and using provided lines and robust estimator method.- Parameters:
lines- 2D lines to estimate a dual conic.qualityScores- quality scores corresponding to each provided line.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have the same size as the list of provided quality scores, or if their size is not greater or equal than MINIMUM_SIZE.
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.qualityScores- quality scores corresponding to each provided line.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 5 lines).
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.lines- 2D lines to estimate a dual conic.qualityScores- quality scores corresponding to each provided line.method- method of a robust estimator algorithm to estimate the best dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have the same size as the list of provided quality scores, or it their size is not greater or equal than MINIMUM_SIZE.
-
create
Creates a dual conic robust estimator based on 2D line samples and using default robust estimator method.- Returns:
- an instance of a dual conic robust estimator.
-
create
Creates a dual conic robust estimator based on 2D line samples and using provided lines and default robust estimator method.- Parameters:
lines- 2D lines to estimate a dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines doesn't have a size greater or equal than MINIMUM_SIZE.
-
create
Creates a dual conic robust estimator based on 2D line samples and using provided listener and default robust estimator method.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.- Returns:
- an instance of a dual conic robust estimator.
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, List<Line2D> lines) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines and default robust estimator method.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.lines- 2D lines to estimate a dual conic.- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines doesn't have a size greater or equal than MINIMUM_SIZE.
-
create
Creates a dual conic robust estimator based on 2D line samples and using default robust estimator method.- Parameters:
qualityScores- quality scores corresponding to each provided line- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 5 lines).
-
create
Creates a dual conic robust estimator based on 2D line samples and using provided lines and default estimator method.- Parameters:
lines- 2D lines to estimate a dual conic.qualityScores- quality scores corresponding to each provided line- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have the same size as the list of provided quality scores, or if their size is not greater or equal than MINIMUM_SIZE.
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, double[] qualityScores) Creates a dual conic robust estimator based on 2D line samples and using provided listener and default estimator method.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.qualityScores- quality scores corresponding to each provided line- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 5 lines).
-
create
public static DualConicRobustEstimator create(DualConicRobustEstimatorListener listener, List<Line2D> lines, double[] qualityScores) Creates a dual conic robust estimator based on 2D line samples and using provided listener and lines and default estimator method.- Parameters:
listener- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.lines- 2D lines to estimate a dual conic.qualityScores- quality scores corresponding to each provided line- Returns:
- an instance of a dual conic robust estimator.
- Throws:
IllegalArgumentException- if provided list of lines don't have the same size as the list of provided quality scores, or if their size is not greater or equal than MINIMUM_SIZE.
-
estimate
public abstract DualConic estimate() throws LockedException, NotReadyException, com.irurueta.numerical.robust.RobustEstimatorExceptionEstimates a dual conic using a robust estimator and the best set of 2D lines that fit into the locus of the estimated dual conic found using the robust estimator.- Returns:
- a dual conic.
- Throws:
LockedException- if robust estimator is locked because an estimation is already in progress.NotReadyException- if provided input data is not enough to start the estimation.com.irurueta.numerical.robust.RobustEstimatorException- if estimation fails for any reason (i.e. numerical instability, no solution available, etc).
-
getMethod
public abstract com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()Returns method being used for robust estimation.- Returns:
- method being used for robust estimation.
-
internalSetLines
Internal method to set list of lines to be used to estimate a dual conic. This method does not check whether estimator is locked or not.- Parameters:
lines- list of lines to be used to estimate a dual conic.- Throws:
IllegalArgumentException- if provided list of lines doesn't have a size greater or equal than MINIMUM_SIZE.
-
residual
Computes the residual between a dual conic and a 2D line.- Parameters:
dc- a dual conic.line- a 2D line.- Returns:
- residual.
-