Class MetricTransformation2DEstimator

java.lang.Object
com.irurueta.geometry.estimators.MetricTransformation2DEstimator

public class MetricTransformation2DEstimator extends Object
Estimator of a 2D metric transformation based on point correspondences. A minimum of 3 non-coincident matched 2D input/output points is required for estimation. If more points are provided an LMSE (Least Mean Squared Error) solution will be found.
  • Field Details

    • MINIMUM_SIZE

      public static final int MINIMUM_SIZE
      Minimum required number of matched points.
      See Also:
    • WEAK_MINIMUM_SIZE

      public static final int WEAK_MINIMUM_SIZE
      For some point configurations a solution can be found with only 2 points.
      See Also:
    • inputPoints

      private List<Point2D> inputPoints
      2D input points.
    • outputPoints

      private List<Point2D> outputPoints
      2D output points.
    • listener

      Listener to be notified of events such as when estimation starts or ends.
    • weakMinimumSizeAllowed

      private boolean weakMinimumSizeAllowed
      Indicates whether estimation can start with only 2 points or not. True allows 2 points, false requires 3.
    • locked

      private boolean locked
      Indicates if this estimator is locked because an estimation is being computed.
  • Constructor Details

    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator()
      Constructor.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(List<Point2D> inputPoints, List<Point2D> outputPoints)
      Constructor.
      Parameters:
      inputPoints - 2D input points.
      outputPoints - 2D output points.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than 2.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(MetricTransformation2DEstimatorListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts or ends.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(MetricTransformation2DEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts or ends.
      inputPoints - 3D input points.
      outputPoints - 3D output points.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than 2.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(boolean weakMinimumSizeAllowed)
      Constructor.
      Parameters:
      weakMinimumSizeAllowed - true allows 3 points, false requires 4.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(List<Point2D> inputPoints, List<Point2D> outputPoints, boolean weakMinimumSizeAllowed)
      Constructor.
      Parameters:
      inputPoints - 2D input points.
      outputPoints - 2D output points.
      weakMinimumSizeAllowed - true allows 3 points, false requires 4.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than 2.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(MetricTransformation2DEstimatorListener listener, boolean weakMinimumSizeAllowed)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts or ends.
      weakMinimumSizeAllowed - true allows 3 points, false requires 4.
    • MetricTransformation2DEstimator

      public MetricTransformation2DEstimator(MetricTransformation2DEstimatorListener listener, List<Point2D> inputPoints, List<Point2D> outputPoints, boolean weakMinimumSizeAllowed)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts or ends.
      inputPoints - 3D input points.
      outputPoints - 3D output points.
      weakMinimumSizeAllowed - true allows 3 points, false requires 4.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than 2.
  • Method Details

    • getInputPoints

      public List<Point2D> getInputPoints()
      Returns list of input points to be used to estimate a metric 2D transformation. Each point in the list of input points must be matched with the corresponding point in the list of output points located at the same position. Hence, both input points and output points must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      Returns:
      list of input points to be used to estimate a metric 2D transformation.
    • getOutputPoints

      public List<Point2D> getOutputPoints()
      Returns list of output points to be used to estimate a metric 2D transformation. Each point in the list of output points must be matched with the corresponding point in the list of input points located at the same position. Hence, both input points and output points must have the same size, and their size must be greater or equal than MINIMUM_SIZE.
      Returns:
      list of output points to be used to estimate a metric 2D transformation.
    • setPoints

      public void setPoints(List<Point2D> inputPoints, List<Point2D> outputPoints) throws LockedException
      Sets list of points to be used to estimate a metric 2D transformation. Points 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:
      inputPoints - list of input points to be used to estimate a metric 2D transformation.
      outputPoints - list of output points to be used to estimate a metric 2D transformation.
      Throws:
      IllegalArgumentException - if provided lists of points 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.
    • getListener

      Returns reference to listener to be notified of events such as when estimation starts or ends.
      Returns:
      listener to be notified of events.
    • setListener

      public void setListener(MetricTransformation2DEstimatorListener listener) throws LockedException
      Sets listener to be notified of events such as when estimation starts or ends.
      Parameters:
      listener - listener to be notified of events.
      Throws:
      LockedException - if estimator is locked.
    • isWeakMinimumSizeAllowed

      public boolean isWeakMinimumSizeAllowed()
      Indicates whether estimation can start with only 2 points or not.
      Returns:
      true allows 2 points, false requires 3.
    • setWeakMinimumSizeAllowed

      public void setWeakMinimumSizeAllowed(boolean weakMinimumSizeAllowed) throws LockedException
      Specifies whether estimation can start with only 2 points or not.
      Parameters:
      weakMinimumSizeAllowed - true allows 2 points, false requires 3.
      Throws:
      LockedException - if estimator is locked.
    • getMinimumPoints

      public int getMinimumPoints()
      Required minimum number of point correspondences to start the estimation. Can be either 2 or 3.
      Returns:
      minimum number of point correspondences.
    • 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.
    • isReady

      public boolean isReady()
      Indicates if estimator is ready to start the metric 2D transformation estimation. This is true when input data (i.e. lists of matched points) are provided and a minimum of MINIMUM_SIZE points are available.
      Returns:
      true if estimator is ready, false otherwise.
    • estimate

      Estimates a metric 2D transformation using the list of matched input and output 2D points. A minimum of 2 matched non-coincident points is required. If more points are provided an LMSE (Least Mean Squared Error) solution will be found.
      Returns:
      estimated metric 2D transformation.
      Throws:
      LockedException - if estimator is locked.
      NotReadyException - if not enough data has been provided.
      CoincidentPointsException - raised if transformation cannot be estimated for some reason (point configuration degeneracy, duplicate points or numerical instabilities).
    • estimate

      Estimates a metric 2D transformation using the list of matched input and output 2D points. A minimum of 2 matched non-coincident points is required. If more points are provided an LMSE (Least Mean Squared Error) solution will be found.
      Parameters:
      result - instance where result will be stored.
      Throws:
      LockedException - if estimator is locked.
      NotReadyException - if not enough data has been provided.
      CoincidentPointsException - raised if transformation cannot be estimated for some reason (point configuration degeneracy, duplicate points or numerical instabilities).
    • computeCentroid

      private static com.irurueta.algebra.Matrix computeCentroid(List<Point2D> points) throws com.irurueta.algebra.AlgebraException
      Computes centroid of provided list of points using inhomogeneous coordinates.
      Parameters:
      points - list of points to compute centroid.
      Returns:
      centroid.
      Throws:
      com.irurueta.algebra.AlgebraException - never thrown.
    • internalSetPoints

      private void internalSetPoints(List<Point2D> inputPoints, List<Point2D> outputPoints)
      Internal method to set lists of points to be used to estimate a metric 2D transformation. This method does not check whether estimator is locked or not.
      Parameters:
      inputPoints - list of input points to be used to estimate a metric 2D transformation.
      outputPoints - list of output points to be used to estimate a metric 2D transformation.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than #getMinimumPoints.