Class WeightedImageOfAbsoluteConicEstimator

java.lang.Object
com.irurueta.ar.calibration.estimators.ImageOfAbsoluteConicEstimator
com.irurueta.ar.calibration.estimators.WeightedImageOfAbsoluteConicEstimator

public class WeightedImageOfAbsoluteConicEstimator extends ImageOfAbsoluteConicEstimator
This class implements an Image of Absolute Conic (IAC) estimator using a weighted algorithm and correspondences. Weights can be used so that homographies assumed to have a better quality (i.e. more precisely estimated) are considered to be more relevant. Aside from enabling constraints whenever possible to obtain more stable and accurate results, its is discouraged to use a large number of homographies, even if they are correctly weighted, since as the number of homographies increase so do the rounding errors.
  • Field Details

    • DEFAULT_MAX_HOMOGRAPHIES

      public static final int DEFAULT_MAX_HOMOGRAPHIES
      Default number of homographies 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:
    • maxHomographies

      private int maxHomographies
      Maximum number of homographies (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 homographies.
  • Constructor Details

    • WeightedImageOfAbsoluteConicEstimator

      public WeightedImageOfAbsoluteConicEstimator()
      Constructor.
    • WeightedImageOfAbsoluteConicEstimator

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

      public WeightedImageOfAbsoluteConicEstimator(List<com.irurueta.geometry.Transformation2D> homographies, double[] weights)
      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.
      weights - array containing a weight amount for each homography. The larger the value of a weight, the most significant the correspondence will be.
      Throws:
      IllegalArgumentException - if not enough homographies are provided for default constraints during IAC estimation.
    • WeightedImageOfAbsoluteConicEstimator

      public WeightedImageOfAbsoluteConicEstimator(List<com.irurueta.geometry.Transformation2D> homographies, double[] weights, ImageOfAbsoluteConicEstimatorListener 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.
      weights - array containing a weight amount for each homography. 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 not enough homographies are provided for default constraints during IAC estimation.
  • Method Details

    • setHomographies

      public void setHomographies(List<com.irurueta.geometry.Transformation2D> homographies)
      Sets list of homographies to estimate IAC. This method override always throws an IllegalArgumentException because it is expected to provide both homographies and their weights.
      Overrides:
      setHomographies in class ImageOfAbsoluteConicEstimator
      Parameters:
      homographies - list of homographies to estimate IAC.
      Throws:
      IllegalArgumentException - always thrown in this implementation.
    • setHomographiesAndWeights

      public void setHomographiesAndWeights(List<com.irurueta.geometry.Transformation2D> homographies, double[] weights) throws com.irurueta.geometry.estimators.LockedException
      Sets list of homographies to estimate IAC along with their corresponding weights.
      Parameters:
      homographies - list of homographies to estimate IAC.
      weights - array containing a weight amount for each homography. 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 not enough homographies are provided for default constraints during IAC estimation.
    • getWeights

      public double[] getWeights()
      Returns array containing a weight amount for each homography. 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.
    • getMaxHomographies

      public int getMaxHomographies()
      Returns maximum number of homographies to be weighted and taken into account.
      Returns:
      maximum number of homographies to be weighted.
    • setMaxHomographies

      public void setMaxHomographies(int maxHomographies) throws com.irurueta.geometry.estimators.LockedException
      Sets maximum number of homographies to be weighted and taken into account. This method must be called after enforcing constraints, because the minimum number of required homographies will be checked based on current settings.
      Parameters:
      maxHomographies - maximum number of homographies to be weighted.
      Throws:
      IllegalArgumentException - if provided value is less than the minimum allowed number of homographies.
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
    • isSortWeightsEnabled

      public boolean isSortWeightsEnabled()
      Indicates if weights are sorted by so that largest weighted homographies 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 homographies 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 list of homographies and weights are available and enough homobraphies have been provided
      Overrides:
      isReady in class ImageOfAbsoluteConicEstimator
      Returns:
      true if estimator is ready, false otherwise.
    • estimate

      public ImageOfAbsoluteConic estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC).
      Specified by:
      estimate in class ImageOfAbsoluteConicEstimator
      Returns:
      estimated IAC.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if estimator is locked.
      com.irurueta.geometry.estimators.NotReadyException - if input has not yet been provided.
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided. Indeed, if provided homographies belong to the group of affine transformations (or other groups contained within such as metric or Euclidean ones), this exception will raise because camera movements will be degenerate. To avoid this exception, homographies must be purely projective.
    • getType

      Returns type of IAC estimator.
      Specified by:
      getType in class ImageOfAbsoluteConicEstimator
      Returns:
      type of IAC estimator.
    • internalSetHomographiesAndWeights

      private void internalSetHomographiesAndWeights(List<com.irurueta.geometry.Transformation2D> homographies, double[] weights)
      Sets list of homographies to estimate IAC. This method does not check whether estimator is locked.
      Parameters:
      homographies - list of homographies to estimate IAC.
      weights - array containing a weight amount for each homography. The larger the value of a weight, the more significant the correspondence will be.
      Throws:
      IllegalArgumentException - if provided list of homographies does not contain enough elements to estimate the IAC using current settings.
    • estimateNoConstraints

      private ImageOfAbsoluteConic estimateNoConstraints() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) without constraints.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.
    • estimateZeroSkewness

      private ImageOfAbsoluteConic estimateZeroSkewness() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) assuming that skewness is zero.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.
    • estimatePrincipalPointAtOrigin

      private ImageOfAbsoluteConic estimatePrincipalPointAtOrigin() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) assuming that principal point is located at origin of coordinates.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.
    • estimateZeroSkewnessAndPrincipalPointAtOrigin

      private ImageOfAbsoluteConic estimateZeroSkewnessAndPrincipalPointAtOrigin() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) assuming that skewness is zero and that principal point is located at origin of coordinates.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.
    • estimateZeroSkewnessAndKnownFocalDistanceAspectRatio

      private ImageOfAbsoluteConic estimateZeroSkewnessAndKnownFocalDistanceAspectRatio() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) assuming that skewness is zero and that aspect ratio of focal distances is known.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.
    • estimateZeroSkewnessPrincipalPointAtOriginAndKnownFocalDistanceAspectRatio

      private ImageOfAbsoluteConic estimateZeroSkewnessPrincipalPointAtOriginAndKnownFocalDistanceAspectRatio() throws ImageOfAbsoluteConicEstimatorException
      Estimates Image of Absolute Conic (IAC) assuming that skewness is zero, principal point is located at origin of coordinates and that aspect ratio of focal distances is known.
      Returns:
      estimated IAC.
      Throws:
      ImageOfAbsoluteConicEstimatorException - if an error occurs during estimation, usually because repeated homographies are provided, or homographies corresponding to degenerate camera movements such as pure parallel translations where no additional data is really provided.