Class AffineTransformation2DRobustEstimator

java.lang.Object
com.irurueta.geometry.estimators.AffineTransformation2DRobustEstimator
Direct Known Subclasses:
LineCorrespondenceAffineTransformation2DRobustEstimator, PointCorrespondenceAffineTransformation2DRobustEstimator

public abstract class AffineTransformation2DRobustEstimator extends Object
This is an abstract class for algorithms to robustly find the best affine 2D transformation for collections of matching 2D points, or 2D lines. Implementations of this class should be able to detect and discard outliers in order to find the best solution.
  • Field Details

    • MINIMUM_SIZE

      public static final int MINIMUM_SIZE
      Minimum number of matched points or matched lines required to estimate an affine 2D transformation.
      See Also:
    • DEFAULT_PROGRESS_DELTA

      public static final float DEFAULT_PROGRESS_DELTA
      Default 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_DELTA
      Minimum allowed value for progress delta.
      See Also:
    • MAX_PROGRESS_DELTA

      public static final float MAX_PROGRESS_DELTA
      Maximum allowed value for progress delta.
      See Also:
    • DEFAULT_CONFIDENCE

      public static final double DEFAULT_CONFIDENCE
      Constant 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_ITERATIONS
      Default maximum allowed number of iterations.
      See Also:
    • MIN_CONFIDENCE

      public static final double MIN_CONFIDENCE
      Minimum allowed confidence value.
      See Also:
    • MAX_CONFIDENCE

      public static final double MAX_CONFIDENCE
      Maximum allowed confidence value.
      See Also:
    • MIN_ITERATIONS

      public static final int MIN_ITERATIONS
      Minimum allowed number of iterations.
      See Also:
    • DEFAULT_REFINE_RESULT

      public static final boolean DEFAULT_REFINE_RESULT
      Indicates that result is refined by default using Levenberg-Marquardt fitting algorithm over found inliers.
      See Also:
    • DEFAULT_KEEP_COVARIANCE

      public static final boolean DEFAULT_KEEP_COVARIANCE
      Indicates that covariance is not kept by default after refining result.
      See Also:
    • mListener

      Listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
    • locked

      protected volatile boolean locked
      Indicates if this estimator is locked because an estimation is being computed.
    • progressDelta

      protected float progressDelta
      Amount of progress variation before notifying a progress change during estimation.
    • confidence

      protected double confidence
      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.
    • maxIterations

      protected int maxIterations
      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.
    • inliersData

      protected com.irurueta.numerical.robust.InliersData inliersData
      Data related to inliers found after estimation.
    • refineResult

      protected boolean refineResult
      Indicates whether result must be refined using Levenberg-Marquardt fitting algorithm over found inliers. If true, inliers will be computed and kept in any implementation regardless of the settings.
    • keepCovariance

      protected boolean keepCovariance
      Indicates whether covariance must be kept after refining result. This setting is only taken into account if result is refined.
    • covariance

      protected com.irurueta.algebra.Matrix covariance
      Estimated covariance of estimated 2D affine transformation. This is only available when result has been refined and covariance is kept.
  • Constructor Details

    • AffineTransformation2DRobustEstimator

      protected AffineTransformation2DRobustEstimator()
      Constructor.
    • AffineTransformation2DRobustEstimator

      protected AffineTransformation2DRobustEstimator(AffineTransformation2DRobustEstimatorListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
  • 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

      public void setListener(AffineTransformation2DRobustEstimatorListener listener) throws LockedException
      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

      public void setProgressDelta(float progressDelta) throws LockedException
      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 the 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

      public void setConfidence(double confidence) throws LockedException
      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

      public void setMaxIterations(int maxIterations) throws LockedException
      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.
    • getInliersData

      public com.irurueta.numerical.robust.InliersData getInliersData()
      Gets data related to inliers found after estimation.
      Returns:
      data related to inliers found after estimation.
    • isResultRefined

      public boolean isResultRefined()
      Indicates whether result must be refined using Levenberg-Marquardt fitting algorithm over found inliers. If ture, inliers will be computed and kept in any implementation regardless of the settings.
      Returns:
      true to refine result, false to simply use result found by robust estimator without further refining.
    • setResultRefined

      public void setResultRefined(boolean refineResult) throws LockedException
      Specifies whether result must be refined using Levenberg-Marquardt fitting algorithm over found inliers.
      Parameters:
      refineResult - true to refine result, false to simply use result found by robust estimator without further refining.
      Throws:
      LockedException - if estimator is locked.
    • isCovarianceKept

      public boolean isCovarianceKept()
      Indicates whether covariance must be kept after refining result. This setting is only taken into account if result is refined.
      Returns:
      true if covariance must be kept after refining result, false otherwise.
    • setCovarianceKept

      public void setCovarianceKept(boolean keepCovariance) throws LockedException
      Specifies whether covariance must be kept after refining result. This setting is only taken into account if result is refined.
      Parameters:
      keepCovariance - true if covariance must be kept after refining result, false otherwise.
      Throws:
      LockedException - if estimator is locked.
    • getCovariance

      public com.irurueta.algebra.Matrix getCovariance()
      Gets estimated covariance of estimated 3D point if available. This is only available when result has been refined and covariance is kept.
      Returns:
      estimated covariance or null.
    • estimate

      public abstract AffineTransformation2D estimate() throws LockedException, NotReadyException, com.irurueta.numerical.robust.RobustEstimatorException
      Estimates an affine 2D transformation using a robust estimator and the best set of matched 2D point or line correspondences found using the robust estimator.
      Returns:
      an affine 2D transformation.
      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
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(List<Point2D> inputPoints, List<Point2D> outputPoints, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using provided robust estimator method
      Parameters:
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(AffineTransformation2DRobustEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using provided robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(List<Point2D> inputPoints, List<Point2D> outputPoints, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using provided robust estimator method
      Parameters:
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched points.
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(AffineTransformation2DRobustEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using provided robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched points.
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(List<Point2D> inputPoints, List<Point2D> outputPoints)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using default robust estimator method
      Parameters:
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(AffineTransformation2DRobustEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using default robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(List<Point2D> inputPoints, List<Point2D> outputPoints, double[] qualityScores)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using default robust estimator method
      Parameters:
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched points.
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromPoints

      public static AffineTransformation2DRobustEstimator createFromPoints(AffineTransformation2DRobustEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints, double[] qualityScores)
      Creates an affine 2D transformation estimator based on 2D point correspondences and using default robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputPoints - list of input points to be used to estimate an affine 2D transformation
      outputPoints - list of output points to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched points.
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(List<Line2D> inputLines, List<Line2D> outputLines, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using provided robust estimator method
      Parameters:
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(AffineTransformation2DRobustEstimatorListener listener, List<Line2D> inputLines, List<Line2D> outputLines, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using provided robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(List<Line2D> inputLines, List<Line2D> outputLines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using provided robust estimator method
      Parameters:
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched lines.
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(AffineTransformation2DRobustEstimatorListener listener, List<Line2D> inputLines, List<Line2D> outputLines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using provided robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched lines.
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(List<Line2D> inputLines, List<Line2D> outputLines)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method
      Parameters:
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(AffineTransformation2DRobustEstimatorListener listener, List<Line2D> inputLines, List<Line2D> outputLines)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(List<Line2D> inputLines, List<Line2D> outputLines, double[] qualityScores)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method
      Parameters:
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched points.
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • createFromLines

      public static AffineTransformation2DRobustEstimator createFromLines(AffineTransformation2DRobustEstimatorListener listener, List<Line2D> inputLines, List<Line2D> outputLines, double[] qualityScores)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes
      inputLines - list of input lines to be used to estimate an affine 2D transformation
      outputLines - list of output lines to be used to estimate an affine 2D transformation
      qualityScores - quality scores corresponding to each pair of matched lines.
      Returns:
      an instance of affine 2D transformation estimator
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE
    • getRefinementStandardDeviation

      protected abstract double getRefinementStandardDeviation()
      Gets standard deviation used for Levenberg-Marquardt fitting during refinement. Returned value gives an indication of how much variance each residual has. Typically, this value is related to the threshold used on each robust estimation, since residuals of found inliers are within the range of such threshold.
      Returns:
      standard deviation used for refinement.