Class ImageOfAbsoluteConicRobustEstimator
java.lang.Object
com.irurueta.ar.calibration.estimators.ImageOfAbsoluteConicRobustEstimator
- Direct Known Subclasses:
LMedSImageOfAbsoluteConicRobustEstimator
,MSACImageOfAbsoluteConicRobustEstimator
,PROMedSImageOfAbsoluteConicRobustEstimator
,PROSACImageOfAbsoluteConicRobustEstimator
,RANSACImageOfAbsoluteConicRobustEstimator
This is an abstract class for algorithms to robustly find the best
ImageOfAbsoluteConic (IAC) for provided collection of 2D homographies.
Implementions of this class should be able to detect and discard outliers
in order to find the best solution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
Amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).static final double
Constant defining default confidence of the estimated result, which is 99%.static final int
Default maximum allowed number of iterations.static final float
Default amount of progress variation before notifying a change in estimation progress.static final com.irurueta.numerical.robust.RobustEstimatorMethod
Default robust estimator method when none is provided.private com.irurueta.algebra.Matrix
Matrix representation of an homography.protected List<com.irurueta.geometry.Transformation2D>
Homographies to estimate image of absolute conic (IAC).protected final LMSEImageOfAbsoluteConicEstimator
Internal non-robust estimator of IAC.private com.irurueta.algebra.Matrix
IAC matrix for one iteration of the robust estimator.Listener to be notified of events such as when estimation starts, ends or its progress significantly changes.protected boolean
Indicates if this estimator is locked because an estimation is being computed.static final double
Maximum allowed confidence value.static final float
Maximum allowed value for progress delta.protected int
Maximum allowed number of iterations.static final double
Minimum allowed confidence value.static final int
Minimum allowed number of iterations.static final float
Minimum allowed value for progress delta.private com.irurueta.algebra.Matrix
Product multiplication of IAC by the right term.protected float
Amount of progress variation before notifying a progress change during estimation.private double[]
Sub-matrix of homography used as the left term on a matrix multiplication.private com.irurueta.algebra.Matrix
Sub-matrix of homography used as the right term on a matrix multiplication. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
Constructor.protected
ImageOfAbsoluteConicRobustEstimator
(List<com.irurueta.geometry.Transformation2D> homographies) Constructor.protected
ImageOfAbsoluteConicRobustEstimator
(List<com.irurueta.geometry.Transformation2D> homographies, ImageOfAbsoluteConicRobustEstimatorListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate()
Creates an image of absolute conic robust estimator using default method.create
(com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided method.Creates an image of absolute conic robust estimator using provided homographies.Creates an image of absolute conic robust estimator using provided homographies.create
(List<com.irurueta.geometry.Transformation2D> homographies, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided homographies.create
(List<com.irurueta.geometry.Transformation2D> homographies, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided homographies.abstract ImageOfAbsoluteConic
estimate()
Estimates Image of Absolute Conic (IAC).double
Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).double
Returns aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance).List<com.irurueta.geometry.Transformation2D>
Gets list of homographies to estimate IAC.Returns reference to listener to be notified of events such as when estimation starts, ends or its progress significantly changes.int
Returns maximum allowed number of iterations.abstract com.irurueta.numerical.robust.RobustEstimatorMethod
Returns method being used for robust estimation.int
Returns minimum number of required homographies needed to estimate the Imag eof Absolute Conic (IAC).float
Returns amount of progress variation before notifying a progress change during estimation.double[]
Returns quality scores corresponding to each homography.private void
internalSetHomographies
(List<com.irurueta.geometry.Transformation2D> homographies) Sets list of homographies.boolean
Returns boolean indicating whether aspect ratio of focal distances (i.e.boolean
Indicates whether listener has been provided and is available for retrieval.boolean
isLocked()
Indicates if this instance is locked because estimation is being computed.boolean
Returns boolean indicating whether principal point is assumed to be at origin of coordinates or not.boolean
isReady()
Returns value indicating whether required data has been provided so that IAC estimation can start.boolean
Returns boolean indicating whether camera skewness is assumed to be zero or not.protected double
residual
(ImageOfAbsoluteConic iac, com.irurueta.geometry.Transformation2D homography) Computes the residual between an image of absolute conic (IAC) and a 2D transformation (homography).void
setConfidence
(double confidence) Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).void
setFocalDistanceAspectRatio
(double focalDistanceAspectRatio) Sets aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance).void
setFocalDistanceAspectRatioKnown
(boolean focalDistanceAspectRatioKnown) Sets boolean indicating whether aspect ratio of focal distances (i.e.void
setHomographies
(List<com.irurueta.geometry.Transformation2D> homographies) Sets list of homographies to estimate IAC.void
Sets listener to be notified of events such as when estimation starts, ends or its progress significantly changes.void
setMaxIterations
(int maxIterations) Sets maximum allowed number of iterations.void
setPrincipalPointAtOrigin
(boolean principalPointAtOrigin) Sets boolean indicating whether principal point is assumed to be at origin of coordinates or not.void
setProgressDelta
(float progressDelta) Sets amount of progress variation before notifying a progress change during estimation.void
setQualityScores
(double[] qualityScores) Sets quality scores corresponding to each homography.void
setZeroSkewness
(boolean zeroSkewness) Sets boolean indicating whether camera skewness is assumed to be zero or not.
-
Field Details
-
DEFAULT_ROBUST_METHOD
public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHODDefault robust estimator method when none is provided. In general for IAC estimation is best to use PROSAC or RANSAC than any other method, as it provides more robust results. -
DEFAULT_PROGRESS_DELTA
public static final float DEFAULT_PROGRESS_DELTADefault amount of progress variation before notifying a change in estimation progress. By default, this is set to 5%.- See Also:
-
MIN_PROGRESS_DELTA
public static final float MIN_PROGRESS_DELTAMinimum allowed value for progress delta.- See Also:
-
MAX_PROGRESS_DELTA
public static final float MAX_PROGRESS_DELTAMaximum allowed value for progress delta.- See Also:
-
DEFAULT_CONFIDENCE
public static final double DEFAULT_CONFIDENCEConstant defining default confidence of the estimated result, which is 99%. This means that with a probability of 99% estimation will be accurate because chosen sub-samples will be inliers.- See Also:
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONSDefault maximum allowed number of iterations.- See Also:
-
MIN_CONFIDENCE
public static final double MIN_CONFIDENCEMinimum allowed confidence value.- See Also:
-
MAX_CONFIDENCE
public static final double MAX_CONFIDENCEMaximum allowed confidence value.- See Also:
-
MIN_ITERATIONS
public static final int MIN_ITERATIONSMinimum allowed number of iterations.- See Also:
-
homographies
Homographies to estimate image of absolute conic (IAC). -
iacEstimator
Internal non-robust estimator of IAC. -
listener
Listener to be notified of events such as when estimation starts, ends or its progress significantly changes. -
locked
protected boolean lockedIndicates if this estimator is locked because an estimation is being computed. -
progressDelta
protected float progressDeltaAmount of progress variation before notifying a progress change during estimation. -
confidence
protected double confidenceAmount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0. -
maxIterations
protected int maxIterationsMaximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval. -
iacMatrix
private com.irurueta.algebra.Matrix iacMatrixIAC matrix for one iteration of the robust estimator. This is used during residuals estimation. This instance is reused for performance reasons. -
homMatrix
private com.irurueta.algebra.Matrix homMatrixMatrix representation of an homography. This is used during residuals estimation. This instance is reused for performance reasons. -
subMatrixLeft
private double[] subMatrixLeftSub-matrix of homography used as the left term on a matrix multiplication. This is used during residuals estimation. This instance is reused for performance reasons. -
subMatrixRight
private com.irurueta.algebra.Matrix subMatrixRightSub-matrix of homography used as the right term on a matrix multiplication. This is used during residuals estimation. This instance is reused for performance reasons. -
mult1
private com.irurueta.algebra.Matrix mult1Product multiplication of IAC by the right term. This is used during residuals estimation. This instance is reused for performance reasons.
-
-
Constructor Details
-
ImageOfAbsoluteConicRobustEstimator
protected ImageOfAbsoluteConicRobustEstimator()Constructor. -
ImageOfAbsoluteConicRobustEstimator
Constructor.- Parameters:
listener
- listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
-
ImageOfAbsoluteConicRobustEstimator
protected ImageOfAbsoluteConicRobustEstimator(List<com.irurueta.geometry.Transformation2D> homographies) Constructor.- Parameters:
homographies
- list of homographies (2D transformations) used to estimate the image of absolute conic (IAC), which can be used to obtain pinhole camera intrinsic parameters.- Throws:
IllegalArgumentException
- if not enough homographies are provided for default settings. Hence, at least 1 homography must be provided.
-
ImageOfAbsoluteConicRobustEstimator
protected ImageOfAbsoluteConicRobustEstimator(List<com.irurueta.geometry.Transformation2D> homographies, ImageOfAbsoluteConicRobustEstimatorListener listener) Constructor.- Parameters:
homographies
- list of homographies (2D transformations) used to estimate the image of absolute conic (IAC), which can be used to obtain pinhole camera intrinsic parameters.listener
- listener to be notified of events such as when estimation starts, ends or estimation progress changes.- Throws:
IllegalArgumentException
- if not enough homographies are provided for default settings. Hence, at least 1 homography must be provided.
-
-
Method Details
-
isZeroSkewness
public boolean isZeroSkewness()Returns boolean indicating whether camera skewness is assumed to be zero or not. Skewness determines whether LCD sensor cells are properly aligned or not, where zero indicates perfect alignment. Typically, skewness is a value equal or very close to zero.- Returns:
- true if camera skewness is assumed to be zero, otherwise camera skewness is estimated.
-
setZeroSkewness
public void setZeroSkewness(boolean zeroSkewness) throws com.irurueta.geometry.estimators.LockedException Sets boolean indicating whether camera skewness is assumed to be zero or not. Skewness determines whether LCD sensor cells are properly aligned or not, where zero indicates perfect alignment. Typically, skewness is a value equal or very close to zero.- Parameters:
zeroSkewness
- true if camera skewness is assumed to be zero, otherwise camera skewness is estimated.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
isPrincipalPointAtOrigin
public boolean isPrincipalPointAtOrigin()Returns boolean indicating whether principal point is assumed to be at origin of coordinates or not. Typically principal point is located at image center (origin of coordinates), and usually matches the center of radial distortion if it is taken into account.- Returns:
- true if principal point is assumed to be at origin of coordinates, false if principal point must be estimated.
-
setPrincipalPointAtOrigin
public void setPrincipalPointAtOrigin(boolean principalPointAtOrigin) throws com.irurueta.geometry.estimators.LockedException Sets boolean indicating whether principal point is assumed to be at origin of coordinates or not. Typically principal point is located at image center (origin of coordinates), and usually matches the center of radial distortion if it is taken into account.- Parameters:
principalPointAtOrigin
- true if principal point is assumed to bet at origin of coordinates, false if principal point must be estimated- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
isFocalDistanceAspectRatioKnown
public boolean isFocalDistanceAspectRatioKnown()Returns boolean indicating whether aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance) is known or not. Notice that focal distance aspect ratio is not related to image size aspect ratio. Typically, LCD sensor cells are square and hence aspect ratio of focal distances is known and equal to 1. This value is only taken into account if skewness is assumed to be zero, otherwise it is ignored.- Returns:
- true if focal distance aspect ratio is known, false otherwise.
-
setFocalDistanceAspectRatioKnown
public void setFocalDistanceAspectRatioKnown(boolean focalDistanceAspectRatioKnown) throws com.irurueta.geometry.estimators.LockedException Sets boolean indicating whether aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance) is known or not. Notice that focal distance aspect ratio is not related to image size aspect ratio. Typically, LCD sensor cells are square and hence aspect ratio of focal distances is known and equal to 1. This value is only taken into account if skewness is assumed to be zero, otherwise it is ignored.- Parameters:
focalDistanceAspectRatioKnown
- true if focal distance aspect ratio is known, false otherwise.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
getFocalDistanceAspectRatio
public double getFocalDistanceAspectRatio()Returns aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance). This value is only taken into account if skewness is assumed to be zero and focal distance aspect ratio is marked as known, otherwise it is ignored. By default, this is 1.0, since it is taken into account that typically LCD sensor cells are square and hence aspect ratio focal distances is known and equal to 1. Notice that focal distance aspect ratio is not related to image size aspect ratio. Notice that a negative aspect ratio indicates that vertical axis is reversed. This can be useful in some situations where image vertical coordinates are reversed respect to the physical world (i.e. in computer graphics typically image vertical coordinates go downwards, while in physical world they go upwards).- Returns:
- aspect ratio of focal distances.
-
setFocalDistanceAspectRatio
public void setFocalDistanceAspectRatio(double focalDistanceAspectRatio) throws com.irurueta.geometry.estimators.LockedException Sets aspect ratio of focal distances (i.e. vertical focal distance divided by horizontal focal distance). This value is only taken into account if skewness is assumed to be zero and focal distance aspect ratio is marked as known, otherwise it is ignored. By default, this is 1.0, since it is taken into account that typically LCD sensor cells are square and hence aspect ratio focal distances is known and equal to 1. Notice that focal distance aspect ratio is not related to image size aspect ratio. Notice that a negative aspect ratio indicates that vertical axis is reversed. This can be useful in some situations where image vertical coordinates are reversed respect to the physical world (i.e. in computer graphics typically image vertical coordinates go downwards, while in physical world they go upwards).- Parameters:
focalDistanceAspectRatio
- aspect ratio of focal distances to be set- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.IllegalArgumentException
- if focal distance aspect ratio is too close to zero, as it might produce numerical instabilities.
-
getListener
Returns reference to listener to be notified of events such as when estimation starts, ends or its progress significantly changes.- Returns:
- listener to be notified of events.
-
setListener
public void setListener(ImageOfAbsoluteConicRobustEstimatorListener listener) throws com.irurueta.geometry.estimators.LockedException Sets listener to be notified of events such as when estimation starts, ends or its progress significantly changes.- Parameters:
listener
- listener to be notified of events.- Throws:
com.irurueta.geometry.estimators.LockedException
- if robust estimator is locked.
-
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.
-
getProgressDelta
public float getProgressDelta()Returns amount of progress variation before notifying a progress change during estimation.- Returns:
- amount of progress variation before notifying a progress change during estimation.
-
setProgressDelta
public void setProgressDelta(float progressDelta) throws com.irurueta.geometry.estimators.LockedException Sets amount of progress variation before notifying a progress change during estimation.- Parameters:
progressDelta
- amount of progress variation before notifying a progress change during estimation.- Throws:
IllegalArgumentException
- if progress delta is less than zero or greater than 1.com.irurueta.geometry.estimators.LockedException
- if this estimator is locked because an estimation is being computed.
-
getConfidence
public double getConfidence()Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Returns:
- amount of confidence as a value between 0.0 and 1.0.
-
setConfidence
public void setConfidence(double confidence) throws com.irurueta.geometry.estimators.LockedException Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Parameters:
confidence
- confidence to be set as a value between 0.0 and 1.0.- Throws:
IllegalArgumentException
- if provided value is not between 0.0 and 1.0.com.irurueta.geometry.estimators.LockedException
- if this estimator is locked because an estimator is being computed.
-
getMaxIterations
public int getMaxIterations()Returns maximum allowed number of iterations. If maximum allowed number of iterations is achieved without converging to a result when calling estimate(), a RobustEstimatorException will be raised.- Returns:
- maximum allowed number of iterations.
-
setMaxIterations
public void setMaxIterations(int maxIterations) throws com.irurueta.geometry.estimators.LockedException Sets maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.- Parameters:
maxIterations
- maximum allowed number of iterations to be set.- Throws:
IllegalArgumentException
- if provided value is less than 1.com.irurueta.geometry.estimators.LockedException
- if this estimator is locked because an estimation is being computed.
-
getHomographies
Gets list of homographies to estimate IAC.- Returns:
- list of homographies to estimate IAC.
-
setHomographies
public void setHomographies(List<com.irurueta.geometry.Transformation2D> homographies) throws com.irurueta.geometry.estimators.LockedException Sets list of homographies to estimate IAC.- Parameters:
homographies
- list of homographies to estimate IAC.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.IllegalArgumentException
- if provided list of homographies does not contain enough elements to estimate the DIAC using current settings.
-
getMinNumberOfRequiredHomographies
public int getMinNumberOfRequiredHomographies()Returns minimum number of required homographies needed to estimate the Imag eof Absolute Conic (IAC). If no constraints are imposed, then at least 3 homographies are required. For each constraint imposed, one less equation will be required, hence if skewness is assumed to be known (by using its typical value of zero), then only 4 equations will be needed. If also the horizontal and vertical coordinates of the principal point are assumed to be known (by being placed at the 2D origin of coordinates, which is a typical value), then only 2 equations will be needed (1 homography).- Returns:
- minimum number of required homographies required to estimate the IAC.
-
isReady
public boolean isReady()Returns value indicating whether required data has been provided so that IAC estimation can start. If true, estimator is ready to compute the IAC, otherwise more data needs to be provided.- Returns:
- true if estimator is ready, false otherwise.
-
getQualityScores
public double[] getQualityScores()Returns quality scores corresponding to each homography. The larger the score value the better the quality of the homography. This implementation always returns null. Subclasses using quality scores must implement proper behaviour.- Returns:
- quality scores corresponding to each homography.
-
setQualityScores
public void setQualityScores(double[] qualityScores) throws com.irurueta.geometry.estimators.LockedException Sets quality scores corresponding to each homography. The larger the score value the better the quality of the homography. This implementation makes no action. Subclasses using quality scores must implement proper behaviour.- Parameters:
qualityScores
- quality scores corresponding to each homography.- Throws:
com.irurueta.geometry.estimators.LockedException
- if robust estimator is locked because an estimation is already in progress.IllegalArgumentException
- if provided quality scores length is smaller than minimum required number of homographies.
-
estimate
public abstract ImageOfAbsoluteConic estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, com.irurueta.numerical.robust.RobustEstimatorExceptionEstimates Image of Absolute Conic (IAC).- Returns:
- estimated IAC.
- Throws:
com.irurueta.geometry.estimators.LockedException
- if robust estimator is locked because an estimation is already in progress.com.irurueta.geometry.estimators.NotReadyException
- if provided input data is not enough to start the estimation.com.irurueta.numerical.robust.RobustEstimatorException
- if estimation fails for any reason (i.e. numerical instability, no solution available, etc).
-
getMethod
public abstract com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()Returns method being used for robust estimation.- Returns:
- method being used for robust estimation.
-
create
public static ImageOfAbsoluteConicRobustEstimator create(com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided method.- Parameters:
method
- method of a robust estimator algorithm to estimate best IAC.- Returns:
- an instance of an image of absolute conic robust estimator.
-
create
public static ImageOfAbsoluteConicRobustEstimator create(List<com.irurueta.geometry.Transformation2D> homographies, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided homographies.- Parameters:
homographies
- list of homographies.qualityScores
- quality scores corresponding to each homography.method
- method of a robust estimator algorithm to estimate best IAC.- Returns:
- an instance of an image of absolute conic robust estimator.
- Throws:
IllegalArgumentException
- if provided list of homographies and quality scores don't have the same size or size is too short.
-
create
public static ImageOfAbsoluteConicRobustEstimator create(List<com.irurueta.geometry.Transformation2D> homographies, com.irurueta.numerical.robust.RobustEstimatorMethod method) Creates an image of absolute conic robust estimator using provided homographies.- Parameters:
homographies
- list of homographies.method
- method of a robust estimator algorithm to estimate best IAC.- Returns:
- an instance of an image of absolute conic robust estimator.
- Throws:
IllegalArgumentException
- if provided list of homographies is too short.
-
create
Creates an image of absolute conic robust estimator using default method.- Returns:
- an instance of an image of absolute conic robust estimator.
-
create
public static ImageOfAbsoluteConicRobustEstimator create(List<com.irurueta.geometry.Transformation2D> homographies, double[] qualityScores) Creates an image of absolute conic robust estimator using provided homographies.- Parameters:
homographies
- list of homographies.qualityScores
- quality scores corresponding to each point.- Returns:
- an instance of an image of absolute conic robust estimator.
- Throws:
IllegalArgumentException
- if provided list of homographies and quality scores don't have the same size or size is too short.
-
create
public static ImageOfAbsoluteConicRobustEstimator create(List<com.irurueta.geometry.Transformation2D> homographies) Creates an image of absolute conic robust estimator using provided homographies.- Parameters:
homographies
- list of homographies.- Returns:
- an instance of an image of absolute conic robust estimator.
- Throws:
IllegalArgumentException
- if provided list of homographies and is too short.
-
residual
protected double residual(ImageOfAbsoluteConic iac, com.irurueta.geometry.Transformation2D homography) Computes the residual between an image of absolute conic (IAC) and a 2D transformation (homography). Residual is derived from the fact that rotation matrices are orthonormal (i.e. h1'*IAC*h2 = 0 and h1'*IAC*h1 = h2'*IAC*h2 --< h1'*IAC*h1 - h2'*IAC*h2 = 0). The residual will be the average error of those two equations.- Parameters:
iac
- the matrix of an image of absolute conic (IAC)homography
- 2D transformation (homography)- Returns:
- residual.
-
internalSetHomographies
Sets list of homographies. This method does not check whether estimator is locked.- Parameters:
homographies
- list of homographies to estimate IAC.- Throws:
IllegalArgumentException
- if provided list of homographies is null or too small.
-