Class WeightedRadialDistortionEstimator

java.lang.Object
com.irurueta.ar.calibration.estimators.RadialDistortionEstimator
com.irurueta.ar.calibration.estimators.WeightedRadialDistortionEstimator

public class WeightedRadialDistortionEstimator extends RadialDistortionEstimator
This class implements a radial distortion estimator using a weighted algorithm and correspondences. Weights can be used so that correspondences assumed to have a better quality are considered to be more relevant.
  • Field Details

    • DEFAULT_MAX_POINTS

      public static final int DEFAULT_MAX_POINTS
      Default number of points (i.e. correspondences) to be weighted and taken into account.
      See Also:
    • DEFAULT_SORT_WEIGHTS

      public static final boolean DEFAULT_SORT_WEIGHTS
      Indicates if weights are sorted by default so that largest weighted correspondences are used first.
      See Also:
    • maxPoints

      private int maxPoints
      Maximum number of points (i.e. correspondences) to be weighted and taken into account.
    • sortWeights

      private boolean sortWeights
      Indicates if weights are sorted by default so that largest weighted correspondences are used first.
    • weights

      private double[] weights
      Array containing weights for all point correspondences.
  • Constructor Details

    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator()
      Constructor.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(RadialDistortionEstimatorListener listener)
      Constructor with listener.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or estimation progress changes.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights)
      Constructor.
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights, RadialDistortionEstimatorListener listener)
      Constructor.
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      listener - listener to be notified of events such as when estimation starts, ends or estimation progress changes.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(com.irurueta.geometry.Point2D distortionCenter)
      Constructor with distortion center.
      Parameters:
      distortionCenter - Distortion center. This is usually equal to the principal point of an estimated camera. If not set it is assumed to be at the origin of coordinates (0,0).
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(com.irurueta.geometry.Point2D distortionCenter, RadialDistortionEstimatorListener listener)
      Constructor with listener and distortion center.
      Parameters:
      distortionCenter - Distortion center. This is usually equal to the principal point of an estimated camera. If not set it is assumed to be at the origin of coordinates (0,0).
      listener - listener to be notified of events such as when estimation starts, ends or estimation progress changes.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights, com.irurueta.geometry.Point2D distortionCenter)
      Constructor with points and distortion center.
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      distortionCenter - Distortion center. This is usually equal to the principal point of an estimated camera. If not set it is assumed to be at the origin of coordinates (0,0).
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
    • WeightedRadialDistortionEstimator

      public WeightedRadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights, com.irurueta.geometry.Point2D distortionCenter, RadialDistortionEstimatorListener listener)
      Constructor.
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      distortionCenter - Distortion center. This is usually equal to the principal point of an estimated camera. If not set it is assumed to be at the origin of coordinates (0,0).
      listener - listener to be notified of events such as when estimation starts, ends or estimation progress changes.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
  • Method Details

    • setPointsAndWeights

      public void setPointsAndWeights(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights) throws com.irurueta.geometry.estimators.LockedException
      Sets lists of corresponding distorted and undistorted points.
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      IllegalArgumentException - if any of the lists or arrays are null or if provided lists of points don't have the same size and enough points or if the length of the weights array is not equal to the number of point correspondences.
    • areValidPointsAndWeights

      public boolean areValidPointsAndWeights(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights)
      Indicates if lists of corresponding distorted and undistorted points are valid. Lists are considered valid if they have the same number of points and both have more than the required minimum of correspondences (which is 2).
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      Returns:
      true if lists of points are valid, false otherwise.
    • getWeights

      public double[] getWeights()
      Returns array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      Returns:
      array containing weights for each correspondence.
    • areWeightsAvailable

      public boolean areWeightsAvailable()
      Returns boolean indicating whether weights have been provided and are available for retrieval.
      Returns:
      true if weights are available, false otherwise.
    • getMaxPoints

      public int getMaxPoints()
      Returns maximum number of points (i.e. correspondences) to be weighted and taken into account.
      Returns:
      maximum number of points to be weighted.
    • setMaxPoints

      public void setMaxPoints(int maxPoints) throws com.irurueta.geometry.estimators.LockedException
      Sets maximum number of points (i.e. correspondences) to be weighted and taken into account.
      Parameters:
      maxPoints - maximum number of points to be weighted.
      Throws:
      IllegalArgumentException - if provided value is less than the minimum allowed number of point correspondences.
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
    • isSortWeightsEnabled

      public boolean isSortWeightsEnabled()
      Indicates if weights are sorted by so that largest weighted correspondences are used first.
      Returns:
      true if weights are sorted, false otherwise.
    • setSortWeightsEnabled

      public void setSortWeightsEnabled(boolean sortWeights) throws com.irurueta.geometry.estimators.LockedException
      Specifies whether weights are sorted by so that largest weighted correspondences are used first.
      Parameters:
      sortWeights - true if weights are sorted, false otherwise.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
    • isReady

      public boolean isReady()
      Indicates if this estimator is ready to start the estimation. Estimator will be ready once both lists and weights are available.
      Overrides:
      isReady in class RadialDistortionEstimator
      Returns:
      true if estimator is ready, false otherwise.
    • estimate

      public RadialDistortion estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, RadialDistortionEstimatorException
      Estimates a radial distortion.
      Specified by:
      estimate in class RadialDistortionEstimator
      Returns:
      estimated radial distortion.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      com.irurueta.geometry.estimators.NotReadyException - if input has not yet been provided.
      RadialDistortionEstimatorException - if an error occurs during estimation, usually because input data is not valid.
    • getType

      Returns type of radial distortion estimator.
      Specified by:
      getType in class RadialDistortionEstimator
      Returns:
      type of radial distortion estimator.
    • internalSetPointsAndWeights

      private void internalSetPointsAndWeights(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights)
      Internal method to set list of corresponding points (it does not check if estimator is locked).
      Parameters:
      distortedPoints - list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      undistortedPoints - list of undistorted points.
      weights - array containing a weight amount for each correspondence. The larger the value of a weight, the most significant the correspondence will be.
      Throws:
      IllegalArgumentException - if any of the lists or arrays are null or if provided lists of points don't have the same size and enough points or if the length of the weights array is not equal to the number of point correspondences.