Class WeightedRadialDistortionEstimator
java.lang.Object
com.irurueta.ar.calibration.estimators.RadialDistortionEstimator
com.irurueta.ar.calibration.estimators.WeightedRadialDistortionEstimator
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default number of points (i.e. correspondences) to be weighted and taken into account.static final boolean
Indicates if weights are sorted by default so that largest weighted correspondences are used first.private int
Maximum number of points (i.e. correspondences) to be weighted and taken into account.private boolean
Indicates if weights are sorted by default so that largest weighted correspondences are used first.private double[]
Array containing weights for all point correspondences.Fields inherited from class com.irurueta.ar.calibration.estimators.RadialDistortionEstimator
DEFAULT_ESTIMATOR_TYPE, DEFAULT_FOCAL_LENGTH, DEFAULT_NUM_K_PARAMS, DEFAULT_SKEW, distortedPoints, distortionCenter, horizontalFocalLength, kInv, listener, locked, MIN_K_PARAMS, numKParams, skew, undistortedPoints, verticalFocalLength
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Constructor with listener.WeightedRadialDistortionEstimator
(com.irurueta.geometry.Point2D distortionCenter) Constructor with distortion center.WeightedRadialDistortionEstimator
(com.irurueta.geometry.Point2D distortionCenter, RadialDistortionEstimatorListener listener) Constructor with listener and distortion center.WeightedRadialDistortionEstimator
(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights) Constructor.WeightedRadialDistortionEstimator
(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights, RadialDistortionEstimatorListener listener) Constructor.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.WeightedRadialDistortionEstimator
(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights, com.irurueta.geometry.Point2D distortionCenter, RadialDistortionEstimatorListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.boolean
Returns boolean indicating whether weights have been provided and are available for retrieval.estimate()
Estimates a radial distortion.int
Returns maximum number of points (i.e. correspondences) to be weighted and taken into account.getType()
Returns type of radial distortion estimator.double[]
Returns array containing a weight amount for each correspondence.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).boolean
isReady()
Indicates if this estimator is ready to start the estimation.boolean
Indicates if weights are sorted by so that largest weighted correspondences are used first.void
setMaxPoints
(int maxPoints) Sets maximum number of points (i.e. correspondences) to be weighted and taken into account.void
setPointsAndWeights
(List<com.irurueta.geometry.Point2D> distortedPoints, List<com.irurueta.geometry.Point2D> undistortedPoints, double[] weights) Sets lists of corresponding distorted and undistorted points.void
setSortWeightsEnabled
(boolean sortWeights) Specifies whether weights are sorted by so that largest weighted correspondences are used first.Methods inherited from class com.irurueta.ar.calibration.estimators.RadialDistortionEstimator
arePointsAvailable, areValidPoints, create, create, getDistortedPoints, getDistortionCenter, getHorizontalFocalLength, getIntrinsic, getListener, getMinNumberOfMatchedPoints, getNumKParams, getSkew, getUndistortedPoints, getVerticalFocalLength, isLocked, setDistortionCenter, setHorizontalFocalLength, setIntrinsic, setIntrinsic, setListener, setNumKParams, setPoints, setSkew, setVerticalFocalLength
-
Field Details
-
DEFAULT_MAX_POINTS
public static final int DEFAULT_MAX_POINTSDefault number of points (i.e. correspondences) to be weighted and taken into account.- See Also:
-
DEFAULT_SORT_WEIGHTS
public static final boolean DEFAULT_SORT_WEIGHTSIndicates if weights are sorted by default so that largest weighted correspondences are used first.- See Also:
-
maxPoints
private int maxPointsMaximum number of points (i.e. correspondences) to be weighted and taken into account. -
sortWeights
private boolean sortWeightsIndicates if weights are sorted by default so that largest weighted correspondences are used first. -
weights
private double[] weightsArray containing weights for all point correspondences.
-
-
Constructor Details
-
WeightedRadialDistortionEstimator
public WeightedRadialDistortionEstimator()Constructor. -
WeightedRadialDistortionEstimator
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 classRadialDistortionEstimator
- Returns:
- true if estimator is ready, false otherwise.
-
estimate
public RadialDistortion estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, RadialDistortionEstimatorExceptionEstimates a radial distortion.- Specified by:
estimate
in classRadialDistortionEstimator
- 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 classRadialDistortionEstimator
- 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.
-