Class PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator


public class PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator extends EPnPPointCorrespondencePinholeCameraRobustEstimator
Finds the best pinhole camera for provided collections of matched 2D/3D points using PROMedS + EPnP algorithms.
  • Field Details

    • DEFAULT_STOP_THRESHOLD

      public static final double DEFAULT_STOP_THRESHOLD
      Default value to be used for stop threshold. Stop threshold can be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      See Also:
    • MIN_STOP_THRESHOLD

      public static final double MIN_STOP_THRESHOLD
      Minimum allowed stop threshold value.
      See Also:
    • stopThreshold

      private double stopThreshold
      Threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. The stop threshold can be used to prevent the LMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
    • qualityScores

      private double[] qualityScores
      Quality scores corresponding to each pair of matched points. The larger the score value the better the quality of the matching.
  • Constructor Details

    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator()
      Constructor.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(List<Point3D> points3D, List<Point2D> points2D)
      Constructor with lists of points to be used to estimate a pinhole camera. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than required minimum size (6 correspondences).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, List<Point3D> points3D, List<Point2D> points2D)
      Constructor with listener and lists of points to be used ot estimate a pinhole camera. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than required minimum size (6 correspondences).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(double[] qualityScores)
      Constructor.
      Parameters:
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 3 samples).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(List<Point3D> points3D, List<Point2D> points2D, double[] qualityScores)
      Constructor with lists of points to be used to estimate a pinhole camera. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided lists of points and array of quality scores don't have the same size or their size is smaller than 6 correspondences.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, double[] qualityScores)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 3 samples).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, List<Point3D> points3D, List<Point2D> points2D, double[] qualityScores)
      Constructor with listener and lists of points to be used ot estimate a pinhole camera. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraIntrinsicParameters intrinsic)
      Constructor with intrinsic parameters.
      Parameters:
      intrinsic - intrinsic parameters of camera to be estimated.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraIntrinsicParameters intrinsic, List<Point3D> points3D, List<Point2D> points2D)
      Constructor with lists of points to be used to estimate a pinhole camera and intrinsic parameters. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      intrinsic - intrinsic parameters of camera to be estimated.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than required minimum size (6 correspondences).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, PinholeCameraIntrinsicParameters intrinsic)
      Constructor with intrinsic parameters and listener.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      intrinsic - intrinsic parameters of camera to be estimated.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, PinholeCameraIntrinsicParameters intrinsic, List<Point3D> points3D, List<Point2D> points2D)
      Constructor with listener and lists of points to be used ot estimate a pinhole camera and intrinsic parameters. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      intrinsic - intrinsic parameters of camera to be estimated.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists of points don't have the same size or their size is smaller than required minimum size (6 correspondences).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraIntrinsicParameters intrinsic, double[] qualityScores)
      Constructor with quality scores and intrinsic parameters.
      Parameters:
      intrinsic - intrinsic parameters of camera to be estimated.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 3 samples).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraIntrinsicParameters intrinsic, List<Point3D> points3D, List<Point2D> points2D, double[] qualityScores)
      Constructor with lists of points to be used to estimate a pinhole camera. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      intrinsic - intrinsic parameters of camera to be estimated.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided lists of points and array of quality scores don't have the same size or their size is smaller than 6 correspondences.
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, PinholeCameraIntrinsicParameters intrinsic, double[] qualityScores)
      Constructor.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      intrinsic - intrinsic parameters of camera to be estimated.
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 3 samples).
    • PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator

      public PROMedSEPnPPointCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, PinholeCameraIntrinsicParameters intrinsic, List<Point3D> points3D, List<Point2D> points2D, double[] qualityScores)
      Constructor with listener and lists of points to be used ot estimate a pinhole camera and intrinsic parameters. Points in the list located at the same position are considered to be matched. Hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_POINT_CORRESPONDENCES.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      intrinsic - intrinsic parameters of camera to be estimated.
      points3D - list of 3D points used to estimate a pinhole camera.
      points2D - list of corresponding projected 2D points used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched points.
      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

    • getStopThreshold

      public double getStopThreshold()
      Returns threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. As in LMedS, the stop threshold can be used to prevent the PROMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      Returns:
      stop threshold to stop the algorithm prematurely when a certain accuracy has been reached.
    • setStopThreshold

      public void setStopThreshold(double stopThreshold) throws LockedException
      Sets threshold to be used to keep the algorithm iterating in case that best estimated threshold using median of residuals is not small enough. Once a solution is found that generates a threshold below this value, the algorithm will stop. As in LMedS, the stop threshold can be used to prevent the PROMedS algorithm iterating too many times in cases where samples have a very similar accuracy. For instance, in cases where proportion of outliers is very small (close to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would iterate for a long time trying to find the best solution when indeed there is no need to do that if a reasonable threshold has already been reached. Because of this behaviour the stop threshold can be set to a value much lower than the one typically used in RANSAC, and yet the algorithm could still produce even smaller thresholds in estimated results.
      Parameters:
      stopThreshold - stop threshold to stop the algorithm prematurely when a certain accuracy has been reached.
      Throws:
      IllegalArgumentException - if provided value is zero or negative.
      LockedException - if robust estimator is locked because an estimation is already in progress.
    • getQualityScores

      public double[] getQualityScores()
      Returns quality scores corresponding to each pair of matched points. The larger the score value the better the quality of the matching.
      Overrides:
      getQualityScores in class PointCorrespondencePinholeCameraRobustEstimator
      Returns:
      quality scores corresponding to each pair of matched points.
    • setQualityScores

      public void setQualityScores(double[] qualityScores) throws LockedException
      Sets quality scores corresponding to each pair of matched points. The larger the score value the better the quality of the matching.
      Overrides:
      setQualityScores in class PointCorrespondencePinholeCameraRobustEstimator
      Parameters:
      qualityScores - quality scores corresponding to each pair of matched points.
      Throws:
      LockedException - if robust estimator is locked because an estimation is already in progress.
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE (i.e. 6 samples).
    • isReady

      public boolean isReady()
      Indicates if estimator is ready to start the affine 2D transformation estimation. This is true when input data (i.e. lists of matched points and quality scores) are provided and a minimum of MINIMUM_SIZE points are available.
      Overrides:
      isReady in class EPnPPointCorrespondencePinholeCameraRobustEstimator
      Returns:
      true if estimator is ready, false otherwise.
    • estimate

      public PinholeCamera estimate() throws LockedException, NotReadyException, com.irurueta.numerical.robust.RobustEstimatorException
      Estimates an affine 2D transformation using a robust estimator and the best set of matched 2D point correspondences found using the robust estimator.
      Specified by:
      estimate in class PinholeCameraRobustEstimator
      Returns:
      an affine 2D transformation.
      Throws:
      LockedException - if robust estimator is locked because an estimation is already in progress.
      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 com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()
      Returns method being used for robust estimation.
      Specified by:
      getMethod in class PinholeCameraRobustEstimator
      Returns:
      method being used for robust estimation.
    • getRefinementStandardDeviation

      protected double getRefinementStandardDeviation()
      Gets standard deviation used for Levenberg-Marquardt fitting during refinement. Returned value gives an indication of how much variance each residual has. Typically, this value is related to the threshold used on each robust estimation, since residuals of found inliers are within the range of such threshold.
      Specified by:
      getRefinementStandardDeviation in class PinholeCameraRobustEstimator
      Returns:
      standard deviation used for refinement.
    • internalSetQualityScores

      private void internalSetQualityScores(double[] qualityScores)
      Sets quality scores corresponding to each pair of matched points. This method is used internally and does not check whether instance is locked or not.
      Parameters:
      qualityScores - quality scores to be set.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than MINIMUM_SIZE.