Class LineCorrespondenceAffineTransformation2DRobustEstimator

java.lang.Object
com.irurueta.geometry.estimators.AffineTransformation2DRobustEstimator
com.irurueta.geometry.estimators.LineCorrespondenceAffineTransformation2DRobustEstimator
Direct Known Subclasses:
LMedSLineCorrespondenceAffineTransformation2DRobustEstimator, MSACLineCorrespondenceAffineTransformation2DRobustEstimator, PROMedSLineCorrespondenceAffineTransformation2DRobustEstimator, PROSACLineCorrespondenceAffineTransformation2DRobustEstimator, RANSACLineCorrespondenceAffineTransformation2DRobustEstimator

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

    • DEFAULT_ROBUST_METHOD

      public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHOD
      Default robust estimator method when none is provided.
    • inputLines

      protected List<Line2D> inputLines
      List of lines to be used to estimate an affine 2D transformation. Each line in the list of input lines must be matched with the corresponding line in the list of output lines located at the same position. Hence, both input lines and output lines must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
    • outputLines

      protected List<Line2D> outputLines
      List of lines to be used to estimate an affine 2D transformation. Each point in the list of output lines must be matched with the corresponding line in the list of input lines located at the same position. Hence, both input lines and output lines must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
  • Constructor Details

    • LineCorrespondenceAffineTransformation2DRobustEstimator

      protected LineCorrespondenceAffineTransformation2DRobustEstimator()
      Constructor.
    • LineCorrespondenceAffineTransformation2DRobustEstimator

      protected LineCorrespondenceAffineTransformation2DRobustEstimator(List<Line2D> inputLines, List<Line2D> outputLines)
      Constructor with lists of lines to be used to estimate an affine 2D transformation. Lines in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      Parameters:
      inputLines - list of input lines to be used to estimate an affine 2D transformation.
      outputLines - list of output lines ot be used to estimate an affine 2D transformation.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MINIMUM_SIZE.
    • LineCorrespondenceAffineTransformation2DRobustEstimator

      protected LineCorrespondenceAffineTransformation2DRobustEstimator(AffineTransformation2DRobustEstimatorListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation stars, ends or its progress significantly changes.
    • LineCorrespondenceAffineTransformation2DRobustEstimator

      protected LineCorrespondenceAffineTransformation2DRobustEstimator(AffineTransformation2DRobustEstimatorListener listener, List<Line2D> inputLines, List<Line2D> outputLines)
      Constructor with listener and lists of lines to be used to estimate affine 2D transformation. Lines in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      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.
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE.
  • Method Details

    • getInputLines

      public List<Line2D> getInputLines()
      Returns list of input lines to be used to estimate an affine 2D transformation. Each line in the list of input lines must be matched with the corresponding line in the list of output lines located at the same position. Hence, both input lines and output lines must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      Returns:
      list of input lines to be used to estimate an affine 2D transformation.
    • getOutputLines

      public List<Line2D> getOutputLines()
      Returns list of output lines to be used to estimate an affine 2D transformation. Each line in the list of output lines must be matched with the corresponding line in the list of input lines located at the same position. Hence, both input lines and output lines must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      Returns:
      list of output lines to be used to estimate an affine 2D transformation.
    • setLines

      public final void setLines(List<Line2D> inputLines, List<Line2D> outputLines) throws LockedException
      Sets lists of lines to be used to estimate an affine 2D transformation. Lines in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      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.
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller 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 affine 2D transformation estimation. This is true when input data (i.e. lists of matched lines) are provided and a minimum of MINIMUM_SIZE lines are available.
      Returns:
      true if estimator is ready, false otherwise.
    • getQualityScores

      public double[] getQualityScores()
      Returns quality scores corresponding to each pair of matched lines. The larger the score value the better the quality of the matching. This implementation always returns null. Subclasses using quality scores must implement proper behaviour.
      Returns:
      quality scores corresponding to each pair of matched points.
    • setQualityScores

      public void setQualityScores(double[] qualityScores) throws LockedException
      Sets quality scores corresponding to each pair of matched lines. 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 pair of matched points.
      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. 3 samples).
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using provided robust estimator method.
      Parameters:
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(AffineTransformation2DRobustEstimatorListener listener, 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.
      method - method of a robust estimator algorithm to estimate the best affine 2D transformation.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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:
      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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(AffineTransformation2DRobustEstimatorListener listener, 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.
      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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      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.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      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.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(double[] qualityScores)
      Creates an affine 2D transformation estimator based on 2D line correspondences and using default robust estimator method.
      Parameters:
      qualityScores - quality scores corresponding to each pair of matched points.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • create

      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.
      qualityScores - quality scores corresponding to each pair of matched points.
      Returns:
      an instance of affine 2D transformation estimator.
    • create

      public static LineCorrespondenceAffineTransformation2DRobustEstimator create(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.
    • internalSetLines

      private void internalSetLines(List<Line2D> inputLines, List<Line2D> outputLines)
      Internal method to set lists of lines to be used to estimate an affine 2D transformation. This method does not check whether estimator is locked or not.
      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.
      Throws:
      IllegalArgumentException - if provided lists of lines don't have the same size or their size is smaller than MINIMUM_SIZE.
    • getResidual

      protected static double getResidual(Line2D line, Line2D transformedLine)
      Computes residual by comparing two lines algebraically by doing the dot product of their parameters. A residual of 0 indicates that dot product was 1 or -1 and lines were equal. A residual of 1 indicates that dot product was 0 and lines were orthogonal. If dot product was -1, then although their director vectors are opposed, lines are considered equal, since sign changes are not taken into account.
      Parameters:
      line - originally sampled output line.
      transformedLine - estimated output line obtained after using estimated transformation.
      Returns:
      computed residual.
    • attemptRefine

      protected AffineTransformation2D attemptRefine(AffineTransformation2D transformation)
      Attempts to refine provided solution if refinement is requested. This method returns a refined solution of the same provided solution if refinement is not requested or has failed. If refinement is enabled, and it is requested to keep covariance, this method will also keep covariance of refined transformation.
      Parameters:
      transformation - transformation estimated by a robust estimator without refinement.
      Returns:
      solution after refinement (if requested) or the provided non-refined solution if not requested or refinement failed.