Class RadialDistortionEstimator

java.lang.Object
com.irurueta.ar.calibration.estimators.RadialDistortionEstimator
Direct Known Subclasses:
LMSERadialDistortionEstimator, WeightedRadialDistortionEstimator

public abstract class RadialDistortionEstimator extends Object
This class defines the interface for an estimator of radial distortion
  • Field Details

    • DEFAULT_NUM_K_PARAMS

      public static final int DEFAULT_NUM_K_PARAMS
      Default number of radial distortion parameters.
      See Also:
    • MIN_K_PARAMS

      public static final int MIN_K_PARAMS
      Minimum number of radial distortion parameters.
      See Also:
    • DEFAULT_FOCAL_LENGTH

      public static final double DEFAULT_FOCAL_LENGTH
      Defines default focal length if none is defined.
      See Also:
    • DEFAULT_SKEW

      public static final double DEFAULT_SKEW
      Defines default skewness if none is defined.
      See Also:
    • DEFAULT_ESTIMATOR_TYPE

      public static final RadialDistortionEstimatorType DEFAULT_ESTIMATOR_TYPE
      Default estimator type.
    • locked

      protected boolean locked
      True when estimator is estimating radial distortion.
    • listener

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

      protected com.irurueta.geometry.Point2D 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).
    • horizontalFocalLength

      protected double horizontalFocalLength
      Horizontal focal length expressed in pixels.
    • verticalFocalLength

      protected double verticalFocalLength
      Vertical focal length expressed in pixels.
    • skew

      protected double skew
      Skew in pixels.
    • kInv

      protected com.irurueta.algebra.Matrix kInv
      Intrinsic parameters matrix.
    • distortedPoints

      protected List<com.irurueta.geometry.Point2D> distortedPoints
      List of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
    • undistortedPoints

      protected List<com.irurueta.geometry.Point2D> undistortedPoints
      List of undistorted points.
    • numKParams

      protected int numKParams
      Number of radial distortion parameters to estimate.
  • Constructor Details

    • RadialDistortionEstimator

      protected RadialDistortionEstimator()
      Constructor.
    • RadialDistortionEstimator

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

      protected RadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints)
      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.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size.
    • RadialDistortionEstimator

      protected RadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, 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.
      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.
    • RadialDistortionEstimator

      protected RadialDistortionEstimator(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).
    • RadialDistortionEstimator

      protected RadialDistortionEstimator(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.
    • RadialDistortionEstimator

      protected RadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, 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.
      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.
    • RadialDistortionEstimator

      protected RadialDistortionEstimator(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, 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.
      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.
  • Method Details

    • getListener

      public RadialDistortionEstimatorListener getListener()
      Returns listener to be notified of events such as when estimation starts, ends or estimation progress changes.
      Returns:
      listener to be notified of events.
    • setListener

      public void setListener(RadialDistortionEstimatorListener listener) throws com.irurueta.geometry.estimators.LockedException
      Sets listener to be notified of events such as when estimation starts, ends or estimation progress changes.
      Parameters:
      listener - listener to be notified of events.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
    • isLocked

      public boolean isLocked()
      Indicates whether this instance is locked.
      Returns:
      true if this estimator is busy estimating a camera, false otherwise.
    • setPoints

      public void setPoints(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints) throws com.irurueta.geometry.estimators.LockedException
      Sets list 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.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      IllegalArgumentException - if provided lists of points don't have the same size.
    • getDistortedPoints

      public List<com.irurueta.geometry.Point2D> getDistortedPoints()
      Returns list of distorted points. Distorted points are obtained after radial distortion is applied to an undistorted point.
      Returns:
      list of distorted points.
    • getUndistortedPoints

      public List<com.irurueta.geometry.Point2D> getUndistortedPoints()
      Returns list of undistorted points.
      Returns:
      list of undistorted points.
    • getDistortionCenter

      public com.irurueta.geometry.Point2D getDistortionCenter()
      Returns 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).
      Returns:
      distortion center or null.
    • setDistortionCenter

      public void setDistortionCenter(com.irurueta.geometry.Point2D distortionCenter) throws com.irurueta.geometry.estimators.LockedException
      Sets 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).
      Parameters:
      distortionCenter - distortion center, or null if set at origin of coordinates.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
    • getHorizontalFocalLength

      public double getHorizontalFocalLength()
      Returns horizontal focal length expressed in pixels.
      Returns:
      horizontal focal length expressed in pixels.
    • setHorizontalFocalLength

      public void setHorizontalFocalLength(double horizontalFocalLength) throws com.irurueta.geometry.estimators.LockedException, RadialDistortionException
      Sets horizontal focal length expressed in pixels.
      Parameters:
      horizontalFocalLength - horizontal focal length expressed in pixels.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      RadialDistortionException - if provided value is degenerate (i.e. zero).
    • getVerticalFocalLength

      public double getVerticalFocalLength()
      Returns vertical focal length expressed in pixels.
      Returns:
      vertical focal length expressed in pixels.
    • setVerticalFocalLength

      public void setVerticalFocalLength(double verticalFocalLength) throws com.irurueta.geometry.estimators.LockedException, RadialDistortionException
      Sets vertical focal length expressed in pixels.
      Parameters:
      verticalFocalLength - vertical focal length expressed in pixels.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      RadialDistortionException - if provided value is degenerate (i.e. zero).
    • getSkew

      public double getSkew()
      Returns skew expressed in pixels.
      Returns:
      skew expressed in pixels.
    • setSkew

      public void setSkew(double skew) throws com.irurueta.geometry.estimators.LockedException
      Sets skew expressed in pixels.
      Parameters:
      skew - skew expressed in pixels.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
    • setIntrinsic

      public final void setIntrinsic(com.irurueta.geometry.Point2D distortionCenter, double horizontalFocalLength, double verticalFocalLength, double skew) throws com.irurueta.geometry.estimators.LockedException, RadialDistortionException
      Sets intrinsic parameters.
      Parameters:
      distortionCenter - radial distortion center.
      horizontalFocalLength - horizontal focal length expressed in pixels.
      verticalFocalLength - vertical focal length expressed in pixels.
      skew - skew expressed in pixels.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      RadialDistortionException - if focal length is degenerate (i.e. zero).
    • getIntrinsic

      public com.irurueta.geometry.PinholeCameraIntrinsicParameters getIntrinsic()
      Returns pinhole camera intrinsic parameters associated to this estimator.
      Returns:
      pinhole camera intrinsic parameters associated to this estimator.
    • setIntrinsic

      public void setIntrinsic(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic) throws com.irurueta.geometry.estimators.LockedException, RadialDistortionException
      Sets intrinsic parameters for this estimator from pinhole camera intrinsic parameters.
      Parameters:
      intrinsic - intrinsic parameters.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      RadialDistortionException - if focal length is degenerate (i.e. zero).
    • getNumKParams

      public int getNumKParams()
      Returns number of radial distortion parameters to estimate.
      Returns:
      number of radial distortion parameters to estimate.
    • setNumKParams

      public void setNumKParams(int numKParams) throws com.irurueta.geometry.estimators.LockedException
      Sets number of radial distortion parameters to estimate.
      Parameters:
      numKParams - number of radial distortion parameters to estimate.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      IllegalArgumentException - if number of parameters is less than 1.
    • getMinNumberOfMatchedPoints

      public int getMinNumberOfMatchedPoints()
      Returns minimum number of required matched points to compute the radial distortion. This is equal to the number of radial distortion parameters. The larger the number of radial distortion parameters, the larger the number of matched points required. Typically, 2 radial distortion parameters are enough, since the following terms can be safely neglected
      Returns:
      minimum number of required matched points to compute the radial distortion.
    • areValidPoints

      public boolean areValidPoints(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints)
      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.
      Returns:
      true if lists of points are valid, false otherwise.
    • arePointsAvailable

      public boolean arePointsAvailable()
      Indicates if lists of corresponding points have already been provided and are available for retrieval.
      Returns:
      true if available, false otherwise.
    • isReady

      public boolean isReady()
      Indicates if this estimator is ready to start th estimation. This is true when lists of points are provided, having equal size and at least 2 points.
      Returns:
      true if estimator is ready, false otherwise.
    • estimate

      public abstract RadialDistortion estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, RadialDistortionEstimatorException
      Estimates a radial distortion.
      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

      public abstract RadialDistortionEstimatorType getType()
      Returns type of radial distortion estimator.
      Returns:
      type of radial distortion estimator.
    • create

      public static RadialDistortionEstimator create()
      Creates an instance of a radial distortion estimator using default type.
      Returns:
      an instance of a radial distortion estimator.
    • create

      Creates an instance of a radial distortion estimator using provided type.
      Parameters:
      type - type of radial distortion estimator.
      Returns:
      an instance of a radial distortion estimator.
    • setInternalIntrinsic

      private void setInternalIntrinsic(com.irurueta.geometry.Point2D distortionCenter, double horizontalFocalLength, double verticalFocalLength, double skew) throws RadialDistortionException
      Internally sets intrinsic parameters. This method does not check whether estimator is locked.
      Parameters:
      distortionCenter - radial distortion center.
      horizontalFocalLength - horizontal focal length expressed in pixels.
      verticalFocalLength - vertical focal length expressed in pixels.
      skew - skew expressed in pixels.
      Throws:
      RadialDistortionException - if focal length is degenerate (i.e. zero).
    • internalSetPoints

      private void internalSetPoints(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints)
      Sets list of corresponding distorted and undistorted points. This method does not check whether 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.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size.