Class CameraCalibratorSample

java.lang.Object
com.irurueta.ar.calibration.CameraCalibratorSample

public class CameraCalibratorSample extends Object
Contains data obtained from a single picture using the camera. Several samples can be used to calibrate the camera. The more samples are used, typically the better the results.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private com.irurueta.geometry.PinholeCamera
    Estimated camera.
    private com.irurueta.geometry.Point3D
    Estimated camera center.
    private com.irurueta.geometry.Transformation2D
    2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture.
    static final int
    Minimum number of sampled markers that must be provided to estimate an homography.
    private Pattern2D
    Pattern used for camera calibration.
    private com.irurueta.geometry.Rotation3D
    Estimated camera rotation.
    private List<com.irurueta.geometry.Point2D>
    Contains the sampled markers taken from a single picture using the camera.
    private double[]
    Quality scores of sampled markers.
    private List<com.irurueta.geometry.Point2D>
    Contains the sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    CameraCalibratorSample(Pattern2D pattern, List<com.irurueta.geometry.Point2D> sampledMarkers)
    Constructor.
    CameraCalibratorSample(Pattern2D pattern, List<com.irurueta.geometry.Point2D> sampledMarkers, double[] sampledMarkersQualityScores)
    Constructor.
    CameraCalibratorSample(List<com.irurueta.geometry.Point2D> sampledMarkers)
    Constructor.
    CameraCalibratorSample(List<com.irurueta.geometry.Point2D> sampledMarkers, double[] sampledMarkersQualityScores)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    computeCameraPose(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic)
    Computes camera pose using estimated homography and provided intrinsic pinhole camera parameters that have been estimated so far.
    static double[]
    computeSampledMarkersQualityScores(List<com.irurueta.geometry.Point2D> sampledMarkers)
    Computes quality scores of sampled markers by taking into account distance to radial distortion center, which is assumed to be at origin of coordinates (i.e. center of image if principal point is also at center of image).
    static double[]
    computeSampledMarkersQualityScores(List<com.irurueta.geometry.Point2D> sampledMarkers, com.irurueta.geometry.Point2D radialDistortionCenter)
    Computes quality scores of sampled markers by taking into account distance to radial distortion center.
    protected com.irurueta.geometry.Transformation2D
    estimateHomography(com.irurueta.geometry.estimators.PointCorrespondenceProjectiveTransformation2DRobustEstimator estimator, List<com.irurueta.geometry.Point2D> idealPatternMarkers)
    Estimates homography of sampled points respect to the ideal pattern points.
    com.irurueta.geometry.PinholeCamera
    Returns estimated camera.
    com.irurueta.geometry.Point3D
    Returns estimated camera center.
    com.irurueta.geometry.Transformation2D
    Returns 2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture.
    Returns pattern used for camera calibration.
    com.irurueta.geometry.Rotation3D
    Returns estimated camera rotation for this sample.
    List<com.irurueta.geometry.Point2D>
    Obtains sampled markers of the pattern taken from a single picture using the camera.
    double[]
    Returns quality scores of sampled markers.
    protected List<com.irurueta.geometry.Point2D>
    Contains the sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens, so that coordinates are undistorted and follow a pure pinhole camera model.
    protected void
    setCamera(com.irurueta.geometry.PinholeCamera camera)
    Sets estimated camera taking into account estimated intrinsic parameters, amount of rotation and translation respect to the plane formed by the pattern markers, but without taking into account any radial distortion introduced by the lens.
    protected void
    setCameraCenter(com.irurueta.geometry.Point3D cameraCenter)
    Sets estimated camera center.
    protected void
    setHomography(com.irurueta.geometry.Transformation2D homography)
    Sets 2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture.
    void
    Sets pattern used for camera calibration.
    protected void
    setRotation(com.irurueta.geometry.Rotation3D rotation)
    Sets estimated camera rotation for this sample.
    final void
    setSampledMarkers(List<com.irurueta.geometry.Point2D> sampledMarkers)
    Sets sampled markers of the pattern taken from a single picture using the camera.
    final void
    setSampledMarkersQualityScores(double[] sampledMarkersQualityScores)
    Sets quality scores of sampled markers.
    protected void
    setUndistortedMarkers(List<com.irurueta.geometry.Point2D> undistortedMarkers)
    Sets sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens, so that coordinates are undistorted and follow a pure pinhole camera model.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MIN_REQUIRED_SAMPLED_MARKERS

      public static final int MIN_REQUIRED_SAMPLED_MARKERS
      Minimum number of sampled markers that must be provided to estimate an homography.
      See Also:
    • pattern

      private Pattern2D pattern
      Pattern used for camera calibration. Each pattern contains a unique combination of 2D points that must be sampled using the camera to be calibrated.
    • sampledMarkers

      private List<com.irurueta.geometry.Point2D> sampledMarkers
      Contains the sampled markers taken from a single picture using the camera.
    • undistortedMarkers

      private List<com.irurueta.geometry.Point2D> undistortedMarkers
      Contains the sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens.
    • sampledMarkersQualityScores

      private double[] sampledMarkersQualityScores
      Quality scores of sampled markers. These can be used during homography estimation if a robust estimation method such as PROSAC or PROMedS is used.
    • homography

      private com.irurueta.geometry.Transformation2D homography
      2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture.
    • rotation

      private com.irurueta.geometry.Rotation3D rotation
      Estimated camera rotation. This contains the amount of rotation respect to the plane formed by the pattern markers. This is obtained once the IAC of the camera is estimated.
    • cameraCenter

      private com.irurueta.geometry.Point3D cameraCenter
      Estimated camera center. This determines the amount of translation of the camera respect to the plane formed by the pattern markers. This is obtained once the IAC of the camera is estimated.
    • camera

      private com.irurueta.geometry.PinholeCamera camera
      Estimated camera. Estimated pinhole camera taking into account estimated intrinsic parameters and amount of rotation and translation respect to the plane formed by the pattern markers, but without taking into account any radial distortion introduced by the lens.
  • Constructor Details

    • CameraCalibratorSample

      public CameraCalibratorSample()
      Constructor.
    • CameraCalibratorSample

      public CameraCalibratorSample(List<com.irurueta.geometry.Point2D> sampledMarkers)
      Constructor.
      Parameters:
      sampledMarkers - sampled markers of the pattern taken from a single picture using the camera.
      Throws:
      IllegalArgumentException - if provided number of sampled markers is smaller than the required minimum (4) to estimate an homography.
    • CameraCalibratorSample

      public CameraCalibratorSample(List<com.irurueta.geometry.Point2D> sampledMarkers, double[] sampledMarkersQualityScores)
      Constructor.
      Parameters:
      sampledMarkers - sampled markers of the pattern taken from a single picture using the camera.
      sampledMarkersQualityScores - quality scores associated to each provided point for each sampled marker. The higher the value the better the quality assigned to that point.
      Throws:
      IllegalArgumentException - if size of sampled markers or quality scores is smaller than the required minimum (4) to estimate an homography, or if their sizes do not match.
    • CameraCalibratorSample

      public CameraCalibratorSample(Pattern2D pattern, List<com.irurueta.geometry.Point2D> sampledMarkers)
      Constructor.
      Parameters:
      pattern - 2D pattern to use for calibration.
      sampledMarkers - sampled markers of the pattern taken from a single picture using the camera.
      Throws:
      IllegalArgumentException - if provided number of sampled markers is smaller than the required minimum (4) to estimate an homography.
    • CameraCalibratorSample

      public CameraCalibratorSample(Pattern2D pattern, List<com.irurueta.geometry.Point2D> sampledMarkers, double[] sampledMarkersQualityScores)
      Constructor.
      Parameters:
      pattern - 2D pattern to use for calibration.
      sampledMarkers - sampled markers of the pattern taken from a single picture using the camera.
      sampledMarkersQualityScores - quality scores associated to each provided point for each sampled marker. The higher the value the better the quality assigned to that point.
      Throws:
      IllegalArgumentException - if size of sampled markers or quality scores is smaller than the required minimum (4) to estimate an homography, or if their sizes do not match.
  • Method Details

    • getPattern

      public Pattern2D getPattern()
      Returns pattern used for camera calibration. Each pattern contain a unique combination of 2D points that must be sampled using the camera to be calibrated.
      Returns:
      pattern used for camera calibration.
    • setPattern

      public void setPattern(Pattern2D pattern)
      Sets pattern used for camera calibration. Each pattern contains a unique combination of 2D points that must be sampled using the camera to be calibrated.
      Parameters:
      pattern - pattern used for camera calibration.
    • getSampledMarkers

      public List<com.irurueta.geometry.Point2D> getSampledMarkers()
      Obtains sampled markers of the pattern taken from a single picture using the camera.
      Returns:
      sampled markers of the pattern.
    • setSampledMarkers

      public final void setSampledMarkers(List<com.irurueta.geometry.Point2D> sampledMarkers)
      Sets sampled markers of the pattern taken from a single picture using the camera.
      Parameters:
      sampledMarkers - sampled markers of the pattern.
      Throws:
      IllegalArgumentException - if provided number of sampled markers is smaller than the required minimum (4) to estimate an homography.
    • getSampledMarkersQualityScores

      public double[] getSampledMarkersQualityScores()
      Returns quality scores of sampled markers. The higher the quality score value the better the quality assigned to the associated 2D point of a sampled marker. Quality scores are only used if a robust estimation method such as PROSAC or PROMedS is used for homography estimation
      Returns:
      quality scores of sampled markers.
    • setSampledMarkersQualityScores

      public final void setSampledMarkersQualityScores(double[] sampledMarkersQualityScores)
      Sets quality scores of sampled markers. The higher the quality score value the better the quality assigned to the associated 2D point of a sampled marker. Quality scores are only used if a robust estimation method such as PROSAC or PROMedS is used for homography estimation.
      Parameters:
      sampledMarkersQualityScores - quality scores of sampled markers.
      Throws:
      IllegalArgumentException - if provided number of quality scores is smaller than the required minimum (4) to estimate an homography.
    • computeSampledMarkersQualityScores

      public static double[] computeSampledMarkersQualityScores(List<com.irurueta.geometry.Point2D> sampledMarkers, com.irurueta.geometry.Point2D radialDistortionCenter)
      Computes quality scores of sampled markers by taking into account distance to radial distortion center. Typically, the farther a sample is to the radial distortion, the more likely it is to be distorted, and hence, the less reliable will be.
      Parameters:
      sampledMarkers - sampled markers of the pattern.
      radialDistortionCenter - location where radial distortion center is assumed to be. If null, it is assumed that center is at origin of coordinates (i.e. center of image if principal point is also at center of image).
      Returns:
      quality scores of sampled markers.
    • computeSampledMarkersQualityScores

      public static double[] computeSampledMarkersQualityScores(List<com.irurueta.geometry.Point2D> sampledMarkers)
      Computes quality scores of sampled markers by taking into account distance to radial distortion center, which is assumed to be at origin of coordinates (i.e. center of image if principal point is also at center of image).
      Parameters:
      sampledMarkers - sampled markers of the pattern.
      Returns:
      quality scores of sampled markers.
    • getUndistortedMarkers

      protected List<com.irurueta.geometry.Point2D> getUndistortedMarkers()
      Contains the sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens, so that coordinates are undistorted and follow a pure pinhole camera model. Coordinates of undistorted markers might change during camera calibration while the radial distortion parameters are refined.
      Returns:
      sampled markers of the pattern accounting for lens radial distortion.
    • setUndistortedMarkers

      protected void setUndistortedMarkers(List<com.irurueta.geometry.Point2D> undistortedMarkers)
      Sets sampled markers of the pattern but accounting for the distortion effect introduced by the camera lens, so that coordinates are undistorted and follow a pure pinhole camera model. This method is for internal purposes only, and it is called while the camera radial distortion parameters are being computed.
      Parameters:
      undistortedMarkers - sampled markers of the pattern accounting for lens radial distortion.
    • getHomography

      public com.irurueta.geometry.Transformation2D getHomography()
      Returns 2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture.
      Returns:
      homography of the sampled pattern points respect to the ideal ones.
    • setHomography

      protected void setHomography(com.irurueta.geometry.Transformation2D homography)
      Sets 2D homography estimated from the sampled pattern points respect to the ideal ones using a single picture. This method is for internal purposes only, and it is called while the IAC is being estimated.
      Parameters:
      homography - homography to be set.
    • getRotation

      public com.irurueta.geometry.Rotation3D getRotation()
      Returns estimated camera rotation for this sample. This contains the amount of rotation respect to the plane formed by the pattern markers for the picture associated to this sample. This is obtained once the IAC of the camera is estimated.
      Returns:
      estimated camera rotation for this sample.
    • setRotation

      protected void setRotation(com.irurueta.geometry.Rotation3D rotation)
      Sets estimated camera rotation for this sample. This contains the amount of rotation respect to the plane formed by the pattern markers for the picture associated to this sample. This is obtained once the IAC of the camera is estimated. This method is for internal purposes only and might only be called if camera rotation is required during radial distortion estimation, or if rotation is requested for some other purpose.
      Parameters:
      rotation - camera rotation for this sample.
    • getCameraCenter

      public com.irurueta.geometry.Point3D getCameraCenter()
      Returns estimated camera center. This determines the amount of translation of the camera respect to the plane formed by the pattern markers. This is obtained once the IAC of the camera is estimated.
      Returns:
      estimated camera center.
    • setCameraCenter

      protected void setCameraCenter(com.irurueta.geometry.Point3D cameraCenter)
      Sets estimated camera center. This determines the amount of translation of the camera respect to the plane formed by the pattern markers. This is obtained once the IAC of the camera is estimated.
      Parameters:
      cameraCenter - estimated camera center.
    • getCamera

      public com.irurueta.geometry.PinholeCamera getCamera()
      Returns estimated camera. Estimated pinhole camera taking into account estimated intrinsic parameters and amount of rotation and translation respect to the plane formed by the pattern markers, but without taking into account any radial distortion introduced by the lens.
      Returns:
      estimated camera.
    • setCamera

      protected void setCamera(com.irurueta.geometry.PinholeCamera camera)
      Sets estimated camera taking into account estimated intrinsic parameters, amount of rotation and translation respect to the plane formed by the pattern markers, but without taking into account any radial distortion introduced by the lens. This method is for internal purposes only and might only be called if camera is required during radial distortion estimation, or if camera is requested for some other purpose.
      Parameters:
      camera - estimated camera.
    • estimateHomography

      protected com.irurueta.geometry.Transformation2D estimateHomography(com.irurueta.geometry.estimators.PointCorrespondenceProjectiveTransformation2DRobustEstimator estimator, List<com.irurueta.geometry.Point2D> idealPatternMarkers) throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, com.irurueta.numerical.robust.RobustEstimatorException, com.irurueta.geometry.CoincidentPointsException
      Estimates homography of sampled points respect to the ideal pattern points. Undistorted sampled taking into account radial distortion will be taken into account whenever possible.
      Parameters:
      estimator - a robust estimator for the homography. It will only be used if more than 4 markers are provided.
      idealPatternMarkers - ideal marker coordinates of the pattern. This contains measures expressed in meters so that camera can be calibrated against real measures.
      Returns:
      an homography.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if robust estimator is locked because computations are already in progress.
      com.irurueta.geometry.estimators.NotReadyException - if provided data to compute homography is not enough, or it is invalid.
      com.irurueta.numerical.robust.RobustEstimatorException - if robust estimation of homography failed. This typically happens when not enough inliers are found or configuration of points to estimate homography is degenerate.
      com.irurueta.geometry.CoincidentPointsException - if configuration of points to estimate homography is degenerate.
    • computeCameraPose

      protected void computeCameraPose(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic) throws CalibrationException
      Computes camera pose using estimated homography and provided intrinsic pinhole camera parameters that have been estimated so far.
      Parameters:
      intrinsic - intrinsic pinhole camera parameters.
      Throws:
      CalibrationException - if something fails.