Class LinePlaneCorrespondencePinholeCameraRobustEstimator

java.lang.Object
com.irurueta.geometry.estimators.PinholeCameraRobustEstimator
com.irurueta.geometry.estimators.LinePlaneCorrespondencePinholeCameraRobustEstimator
Direct Known Subclasses:
DLTLinePlaneCorrespondencePinholeCameraRobustEstimator

public abstract class LinePlaneCorrespondencePinholeCameraRobustEstimator extends PinholeCameraRobustEstimator
This is an abstract class for algorithms to robustly find the best pinhole camera for collections of matched lines and planes. Implementations of this class should be able to detect and discard outliers in order to find the best solution.
  • Field Details

    • MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES

      public static final int MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES
      Minimum number of required line/plane correspondences to estimate a camera.
      See Also:
    • DEFAULT_ROBUST_METHOD

      public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHOD
      Default robust estimator method when none is provided.
    • planes

      protected List<Plane> planes
      List of matched planes.
    • lines

      protected List<Line2D> lines
      List of matched lines.
    • residualTestPlane

      private final Plane residualTestPlane
      Plane to be reused when computing residuals.
  • Constructor Details

    • LinePlaneCorrespondencePinholeCameraRobustEstimator

      protected LinePlaneCorrespondencePinholeCameraRobustEstimator()
      Constructor.
    • LinePlaneCorrespondencePinholeCameraRobustEstimator

      protected LinePlaneCorrespondencePinholeCameraRobustEstimator(List<Plane> planes, List<Line2D> lines)
      Constructor with lists of matched planes and 2D lines to estimate a pinhole camera. Points and lines in the lists 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_LINE_PLANE_CORRESPONDENCES (4 matches).
      Parameters:
      planes - list of planes used to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists don't have the same size or their size is smaller than required minimum size (4 matches).
    • LinePlaneCorrespondencePinholeCameraRobustEstimator

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

      protected LinePlaneCorrespondencePinholeCameraRobustEstimator(PinholeCameraRobustEstimatorListener listener, List<Plane> planes, List<Line2D> lines)
      Constructor with listener and lists of matched planes and 2D lines to estimate a pinhole camera. Points and lines in the lists 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_LINE_PLANE_CORRESPONDENCES (4 matches).
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      planes - list of planes used to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists don't have the same size or their size is smaller than required minimum size (4 matches).
  • Method Details

    • getPlanes

      public List<Plane> getPlanes()
      Returns list of 3D planes to be used to estimate a pinhole camera. Each plane in the list of 3D planes must be matched with a corresponding 2D line resulting from the projection of the 3D plane through the camera to be estimated. Matched lines and planes must be located on the same position in the lists, hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES.
      Returns:
      list of 3D planes to be used to estimate a pinhole camera.
    • getLines

      public List<Line2D> getLines()
      Returns list of 2D lines to be used to estimate a pinhole camera. Each line in the list is the result of the projection of a matched.
      Returns:
      list of 2D lines to be used to estimate a pinhole camera.
    • setLinesAndPlanes

      public final void setLinesAndPlanes(List<Plane> planes, List<Line2D> lines) throws LockedException
      Sets list of matched 3D planes and 2D lines to be used to estimate a pinhole camera. Each plane in the list of 3D planes must be matched with a corresponding 2D line resulting from the projection of the 3D plane through the camera to be estimated. Matched lines and planes must be located on the same position in the lists, hence, both lists must have the same size, and their size must be greater or equal than MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES.
      Parameters:
      planes - 3D planes to be used to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists don't have the same size or their size is smaller than required minimum size (4 matches).
      LockedException - if estimator is locked because a computation is already in progress.
    • isReady

      public boolean isReady()
      Indicates if estimator is ready to start the pinhole camera estimation. This is true when input data (i.e. lists of matched planes and lines) are provided as a minimum of MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES are available.
      Returns:
      true if estimator is ready, false otherwise.
    • getQualityScores

      public double[] getQualityScores()
      Returns quality scores corresponding to each pair of matched samples (plane and line). The larger the score value the better the quality of the matching. This implementation always returns null. Subclasses using quality scores must implement proper behaviour.
      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. This implementation makes no action. Subclasses using quality scores must implement proper behaviour.
      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 MIN_NUMBER_OF_LINE_PLANE_CORRESPONDENCES (i.e. 4 samples).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided robust estimator method.
      Parameters:
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(List<Plane> planes, List<Line2D> lines, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided planes and lines and provided robust estimator method.
      Parameters:
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener and robust estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, List<Plane> planes, List<Line2D> lines, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, planes and lines, and robust estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided quality scores and robust estimator method.
      Parameters:
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than required minimum size (4 samples).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(List<Plane> planes, List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided planes and lines, quality scores and provided robust estimator method.
      Parameters:
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines or quality scores don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, quality scores and robust estimator method.
      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 planes/lines.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided quality scores don't have the required minimum size (4 samples).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, List<Plane> planes, List<Line2D> lines, double[] qualityScores, com.irurueta.numerical.robust.RobustEstimatorMethod method)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, planes and lines, and robust estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      method - method of a robust estimator algorithm to estimate the best pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines or quality scores don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      Creates a pinhole camera robust estimator based on plane/line correspondences and using default robust estimator method.
      Returns:
      an instance of a pinhole camera robust estimator.
    • create

      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided planes and lines and default robust estimator method.
      Parameters:
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener and default estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      Returns:
      an instance of a pinhole camera robust estimator.
    • create

      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, planes and lines, and default robust estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(double[] qualityScores)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided quality scores and default robust estimator method.
      Parameters:
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided quality scores length is smaller than required minimum size (4 samples).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(List<Plane> planes, List<Line2D> lines, double[] qualityScores)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided planes and lines, quality scores and default robust estimator method.
      Parameters:
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines or quality scores don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, double[] qualityScores)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, quality scores and default robust estimator method.
      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 planes/lines.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided quality scores don't have the required minimum size (4 samples).
    • create

      public static LinePlaneCorrespondencePinholeCameraRobustEstimator create(PinholeCameraRobustEstimatorListener listener, List<Plane> planes, List<Line2D> lines, double[] qualityScores)
      Creates a pinhole camera robust estimator based on plane/line correspondences and using provided listener, planes and lines, and default robust estimator method.
      Parameters:
      listener - listener to be notified of events such as when estimation starts, ends or its progress significantly changes.
      planes - list of 3D planes to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      qualityScores - quality scores corresponding to each pair of matched planes/lines.
      Returns:
      an instance of a pinhole camera robust estimator.
      Throws:
      IllegalArgumentException - if provided lists of planes and lines or quality scores don't have the same size or their size is smaller than required minimum size (4 correspondences).
    • attemptRefine

      protected PinholeCamera attemptRefine(PinholeCamera pinholeCamera, double weight)
      Attempt sto refine provided camera.
      Parameters:
      pinholeCamera - camera to be refined.
      weight - weight for suggestion residual.
      Returns:
      refined camera of provided camera if anything fails.
    • singleBackprojectionResidual

      protected double singleBackprojectionResidual(PinholeCamera pinholeCamera, Line2D line, Plane plane)
      Back-projection residual/error for a single line using provided camera.
      Parameters:
      pinholeCamera - camera ot be checked.
      line - line to be back-projected.
      plane - plane to check against.
      Returns:
      dot product distance between back-projected line and plane.
    • internalSetLinesAndPlanes

      private void internalSetLinesAndPlanes(List<Plane> planes, List<Line2D> lines)
      Internal method to set lists of planes and lines to be used to estimate a pinhole camera. This method does not check whether estimator is locked or not.
      Parameters:
      planes - list of 3D planes used to estimate a pinhole camera.
      lines - list of corresponding projected 2D lines used to estimate a pinhole camera.
      Throws:
      IllegalArgumentException - if provided lists of planes/lines don't have the same size or their size is smaller than required minimum size (4 samples).
    • attemptSlowRefine

      private PinholeCamera attemptSlowRefine(PinholeCamera pinholeCamera, double weight)
      Attempts to refine provided camera using a slow but more accurate and stable algorithm by first doing a Powell optimization and then obtaining covariance using Levenberg/Marquardt if needed.
      Parameters:
      pinholeCamera - camera to be refined.
      weight - weight for suggestion residual.
      Returns:
      refined camera or provided camera if anything fails.
    • attemptFastRefine

      private PinholeCamera attemptFastRefine(PinholeCamera pinholeCamera, double weight)
      Attempts to refine provided camera using a fast algorithm based on Levenberg/Marquardt.
      Parameters:
      pinholeCamera - camera to be refined.
      weight - weight for suggestion residual.
      Returns:
      refined camera or provided camera if anything fails.