Package com.irurueta.ar.sfm
Class EssentialMatrixInitialCamerasEstimator
java.lang.Object
com.irurueta.ar.sfm.InitialCamerasEstimator
com.irurueta.ar.sfm.EssentialMatrixInitialCamerasEstimator
Estimates an initial pair of cameras in the metric stratum (up to an
arbitrary scale) using a given fundamental matrix and provided intrinsic
parameters on left and right views (which can be obtained by offline
calibration) to compute the essential matrix and choose the best combination
of rotation and translation on estimated cameras so that triangulated 3D
points obtained from provided matched 2D points are located in front of
the estimated cameras.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CorrectorType
Type of corrector to use to triangulate matched points or null if no corrector needs to be used.static final boolean
Indicates whether triangulated points must be marked as valid (i.e. when they lie in front of both of the estimated cameras) or not.static final boolean
Indicates whether matched 2D points must be triangulated by default.private com.irurueta.geometry.PinholeCameraIntrinsicParameters
Intrinsic parameters to be used for estimated left camera.private List<com.irurueta.geometry.Point2D>
Matched 2D points on left view.private boolean
Marks which of the triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't.private com.irurueta.geometry.PinholeCameraIntrinsicParameters
Intrinsic parameters to be used for estimated right camera.private List<com.irurueta.geometry.Point2D>
Matched 2D points on right view.private List<com.irurueta.geometry.Point3D>
Contains triangulated points.private boolean
Indicates whether matched 2D points need to be triangulated.private BitSet
Contains booleans indicating whether triangulated points are valid (i.e.Fields inherited from class com.irurueta.ar.sfm.InitialCamerasEstimator
DEFAULT_METHOD, estimatedLeftCamera, estimatedRightCamera, fundamentalMatrix, listener, locked
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, InitialCamerasEstimatorListener listener) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, InitialCamerasEstimatorListener listener) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.EssentialMatrixInitialCamerasEstimator
(FundamentalMatrix fundamentalMatrix, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.Constructor.EssentialMatrixInitialCamerasEstimator
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Constructor.EssentialMatrixInitialCamerasEstimator
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, InitialCamerasEstimatorListener listener) Constructor.EssentialMatrixInitialCamerasEstimator
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.EssentialMatrixInitialCamerasEstimator
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.EssentialMatrixInitialCamerasEstimator
(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.EssentialMatrixInitialCamerasEstimator
(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether matched 2D points need to be triangulated or not.boolean
Indicates which triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't.private static int
computeCamerasAndTriangulation
(com.irurueta.geometry.Rotation3D rotation, com.irurueta.geometry.Point2D translation, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera estimatedLeftCamera, com.irurueta.geometry.PinholeCamera estimatedRightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) Computes a pair of cameras for provided rotation and translation using provided intrinsic parameters.void
estimate()
Estimates cameras.static int
generateInitialMetricCamerasFromEssentialMatrix
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, CorrectorType correctorType, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera) Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras.static int
generateInitialMetricCamerasFromEssentialMatrix
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, CorrectorType correctorType, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras.static int
generateInitialMetricCamerasFromEssentialMatrix
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera) Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras.static int
generateInitialMetricCamerasFromEssentialMatrix
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras.Gets type of corrector to use to triangulate matched points or null if no corrector needs to be used.com.irurueta.geometry.PinholeCameraIntrinsicParameters
Gets intrinsic parameters to be used for estimated left camera.List<com.irurueta.geometry.Point2D>
Gets matched 2D points on left view.Returns method used by this estimator.com.irurueta.geometry.PinholeCameraIntrinsicParameters
Gets intrinsic parameters to be used for estimated right camera.List<com.irurueta.geometry.Point2D>
Gets matched 2D points on right view.List<com.irurueta.geometry.Point3D>
Gets triangulated points, if available.Gets bitset indicating which of the triangulated points are valid and which ones aren't.private void
internalSetLeftAndRightPoints
(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Internal method to set matched 2D points on left and right views.boolean
isReady()
Indicates if estimator is ready.void
setCorrectorType
(CorrectorType correctorType) Sets type of corrector to use to triangulate matched points or null if no corrector needs to be used.void
setIntrinsicsForBoth
(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic) Sets the same intrinsic parameters to be used for both estimated left and right cameras.void
setLeftAndRightIntrinsics
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Sets intrinsic parameters to be used for estimated left and right cameras.void
setLeftAndRightPoints
(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Sets matched 2D points on left and right views.void
setLeftIntrinsic
(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic) Sets intrinsic parameters to be used for estimated left camera.void
setLeftPoints
(List<com.irurueta.geometry.Point2D> leftPoints) Sets matched 2D points on left view.void
setPointsTriangulated
(boolean triangulatePoints) Specifies whether matched 2D points need to be triangulated or not.void
setRightIntrinsic
(com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Sets intrinsic parameters to be used for estimated right camera.void
setRightPoints
(List<com.irurueta.geometry.Point2D> rightPoints) Sets matched 2D points on right view.void
setValidTriangulatedPointsMarked
(boolean markValidTriangulatedPoints) Specifies whether triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't.private static void
updateBestSolutionData
(com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints, com.irurueta.geometry.PinholeCamera attemptLeftCamera, com.irurueta.geometry.PinholeCamera attemptRightCamera, List<com.irurueta.geometry.Point3D> attemptTriangulatedPoints, BitSet attemptValidTriangulatedPoints) Updates data for best solution found so far.Methods inherited from class com.irurueta.ar.sfm.InitialCamerasEstimator
create, create, create, create, create, create, create, create, getEstimatedLeftCamera, getEstimatedRightCamera, getFundamentalMatrix, getListener, isLocked, setFundamentalMatrix, setListener
-
Field Details
-
DEFAULT_TRIANGULATE_POINTS
public static final boolean DEFAULT_TRIANGULATE_POINTSIndicates whether matched 2D points must be triangulated by default.- See Also:
-
DEFAULT_MARK_VALID_TRIANGULATED_POINTS
public static final boolean DEFAULT_MARK_VALID_TRIANGULATED_POINTSIndicates whether triangulated points must be marked as valid (i.e. when they lie in front of both of the estimated cameras) or not.- See Also:
-
leftIntrinsic
private com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsicIntrinsic parameters to be used for estimated left camera. -
rightIntrinsic
private com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsicIntrinsic parameters to be used for estimated right camera. -
leftPoints
Matched 2D points on left view. -
rightPoints
Matched 2D points on right view. -
correctorType
Type of corrector to use to triangulate matched points or null if no corrector needs to be used. -
triangulatePoints
private boolean triangulatePointsIndicates whether matched 2D points need to be triangulated. -
markValidTriangulatedPoints
private boolean markValidTriangulatedPointsMarks which of the triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't. -
triangulatedPoints
Contains triangulated points. -
validTriangulatedPoints
Contains booleans indicating whether triangulated points are valid (i.e. lie in front of both estimated cameras) or not.
-
-
Constructor Details
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator()Constructor. -
EssentialMatrixInitialCamerasEstimator
Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Constructor.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.- Parameters:
leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
Constructor.- Parameters:
listener
- listener to handle events raised by this instance.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.listener
- listener to handle events raised by this instance.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.listener
- listener to handle events raised by this instance.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.listener
- listener to handle events raised by this instance.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.listener
- listener to handle events raised by this instance.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.listener
- listener to handle events raised by this instance.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.listener
- listener to handle events raised by this instance.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
EssentialMatrixInitialCamerasEstimator
public EssentialMatrixInitialCamerasEstimator(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, InitialCamerasEstimatorListener listener) Constructor.- Parameters:
fundamentalMatrix
- fundamental matrix relating two views.leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.listener
- listener to handle events raised by this instance.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
-
Method Details
-
getMethod
Returns method used by this estimator.- Specified by:
getMethod
in classInitialCamerasEstimator
- Returns:
- method used by this estimator.
-
isReady
public boolean isReady()Indicates if estimator is ready.- Specified by:
isReady
in classInitialCamerasEstimator
- Returns:
- true if estimator is ready, false otherwise.
-
estimate
public void estimate() throws com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, InitialCamerasEstimationFailedExceptionEstimates cameras.- Specified by:
estimate
in classInitialCamerasEstimator
- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.com.irurueta.geometry.estimators.NotReadyException
- if estimator is not ready.InitialCamerasEstimationFailedException
- if estimation of cameras fails for some reason, typically due to numerical instabilities.
-
getLeftIntrinsic
public com.irurueta.geometry.PinholeCameraIntrinsicParameters getLeftIntrinsic()Gets intrinsic parameters to be used for estimated left camera.- Returns:
- intrinsic parameters to be used for estimated left camera.
-
setLeftIntrinsic
public void setLeftIntrinsic(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic) throws com.irurueta.geometry.estimators.LockedException Sets intrinsic parameters to be used for estimated left camera.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
getRightIntrinsic
public com.irurueta.geometry.PinholeCameraIntrinsicParameters getRightIntrinsic()Gets intrinsic parameters to be used for estimated right camera.- Returns:
- intrinsic parameters to be used for estimated right camera.
-
setRightIntrinsic
public void setRightIntrinsic(com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) throws com.irurueta.geometry.estimators.LockedException Sets intrinsic parameters to be used for estimated right camera.- Parameters:
rightIntrinsic
- intrinsic parameters to be used for estimated right camera.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
setLeftAndRightIntrinsics
public void setLeftAndRightIntrinsics(com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic) throws com.irurueta.geometry.estimators.LockedException Sets intrinsic parameters to be used for estimated left and right cameras.- Parameters:
leftIntrinsic
- intrinsic parameters to be used for estimated left camera.rightIntrinsic
- intrinsic parameters to be used for estimated right camera.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
setIntrinsicsForBoth
public void setIntrinsicsForBoth(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic) throws com.irurueta.geometry.estimators.LockedException Sets the same intrinsic parameters to be used for both estimated left and right cameras.- Parameters:
intrinsic
- intrinsic parameters to be used for both cameras.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
getLeftPoints
Gets matched 2D points on left view.- Returns:
- matched 2D points on left view.
-
setLeftPoints
public void setLeftPoints(List<com.irurueta.geometry.Point2D> leftPoints) throws com.irurueta.geometry.estimators.LockedException Sets matched 2D points on left view.- Parameters:
leftPoints
- matched 2D points on left view.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
getRightPoints
Gets matched 2D points on right view.- Returns:
- matched 2D points on right view.
-
setRightPoints
public void setRightPoints(List<com.irurueta.geometry.Point2D> rightPoints) throws com.irurueta.geometry.estimators.LockedException Sets matched 2D points on right view.- Parameters:
rightPoints
- matched 2D points on right view.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
setLeftAndRightPoints
public void setLeftAndRightPoints(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) throws com.irurueta.geometry.estimators.LockedException Sets matched 2D points on left and right views.- Parameters:
leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.IllegalArgumentException
- if provided lists don't have the same size.
-
getCorrectorType
Gets type of corrector to use to triangulate matched points or null if no corrector needs to be used.- Returns:
- type of corrector to use.
-
setCorrectorType
public void setCorrectorType(CorrectorType correctorType) throws com.irurueta.geometry.estimators.LockedException Sets type of corrector to use to triangulate matched points or null if no corrector needs to be used.- Parameters:
correctorType
- type of corrector to use.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
arePointsTriangulated
public boolean arePointsTriangulated()Indicates whether matched 2D points need to be triangulated or not.- Returns:
- true if 2D points need to be triangulated, false otherwise.
-
setPointsTriangulated
public void setPointsTriangulated(boolean triangulatePoints) throws com.irurueta.geometry.estimators.LockedException Specifies whether matched 2D points need to be triangulated or not.- Parameters:
triangulatePoints
- true if 2D points need to be triangulated, false otherwise.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
areValidTriangulatedPointsMarked
public boolean areValidTriangulatedPointsMarked()Indicates which triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't.- Returns:
- true to mark valid and invalid triangulated points, false otherwise.
-
setValidTriangulatedPointsMarked
public void setValidTriangulatedPointsMarked(boolean markValidTriangulatedPoints) throws com.irurueta.geometry.estimators.LockedException Specifies whether triangulated points are marked as valid (lie in front of both of the estimated cameras) and which ones aren't.- Parameters:
markValidTriangulatedPoints
- true to mark valid and invalid triangulated points, false otherwise.- Throws:
com.irurueta.geometry.estimators.LockedException
- if estimator is locked.
-
getTriangulatedPoints
Gets triangulated points, if available.- Returns:
- triangulated points or null.
-
getValidTriangulatedPoints
Gets bitset indicating which of the triangulated points are valid and which ones aren't.- Returns:
- bitset indicating validity of triangulated points or null if not available.
-
generateInitialMetricCamerasFromEssentialMatrix
public static int generateInitialMetricCamerasFromEssentialMatrix(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera) throws InitialCamerasEstimationFailedException Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras. This method uses default corrector type and does not keep triangulated points or valid triangulated points.- Parameters:
fundamentalMatrix
- fundamental matrix relating both left and right views.leftIntrinsic
- intrinsic parameters to be set on left view. This can be used when cameras have been previously calibrated.rightIntrinsic
- intrinsic parameters to be set on right view. This can be used when cameras have been previously calibrated.leftPoints
- points on left view matched with points on right view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.rightPoints
- points on right view matched with points on left view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.leftCamera
- instance where estimated left camera will be stored.rightCamera
- instance where estimated right camera will be stored.- Returns:
- number of valid triangulated points which lie in front of the two estimated cameras.
- Throws:
InitialCamerasEstimationFailedException
- if estimation of cameras fails for some reason, typically due to numerical instabilities.IllegalArgumentException
- if provided lists of left and right points don't have the same size.
-
generateInitialMetricCamerasFromEssentialMatrix
public static int generateInitialMetricCamerasFromEssentialMatrix(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, CorrectorType correctorType, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera) throws InitialCamerasEstimationFailedException Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras. This method does not keep triangulated points or valid triangulated points.- Parameters:
fundamentalMatrix
- fundamental matrix relating both left and right views.leftIntrinsic
- intrinsic parameters to be set on left view. This can be used when cameras have been previously calibrated.rightIntrinsic
- intrinsic parameters to be set on right view. This can be used when cameras have been previously calibrated.leftPoints
- points on left view matched with points on right view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.rightPoints
- points on right view matched with points on left view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.correctorType
- corrector type to be used to correct 2D points, so they follow the epipolar geometry defined by provided fundamental matrix so that error on triangulated points is reduced. If null, no corrector will be used.leftCamera
- instance where estimated left camera will be stored.rightCamera
- instance where estimated right camera will be stored.- Returns:
- number of valid triangulated points which lie in front of the two estimated cameras.
- Throws:
InitialCamerasEstimationFailedException
- if estimation of cameras fails for some reason, typically due to numerical instabilities.IllegalArgumentException
- if provided lists of left and right points don't have the same size.
-
generateInitialMetricCamerasFromEssentialMatrix
public static int generateInitialMetricCamerasFromEssentialMatrix(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) throws InitialCamerasEstimationFailedException Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras. This method uses default corrector type.- Parameters:
fundamentalMatrix
- fundamental matrix relating both left and right views.leftIntrinsic
- intrinsic parameters to be set on left view. This can be used when cameras have been previously calibrated.rightIntrinsic
- intrinsic parameters to be set on right view. This can be used when cameras have been previously calibrated.leftPoints
- points on left view matched with points on right view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.rightPoints
- points on right view matched with points on left view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.leftCamera
- instance where estimated left camera will be stored.rightCamera
- instance where estimated right camera will be stored.triangulatedPoints
- instance where triangulated 3D points will be stored or null if triangulated points don't need to be kept.validTriangulatedPoints
- instance which indicates which triangulated 3D points are considered valid because they lie in front of both cameras or null if such data doesn't need to be kept.- Returns:
- number of valid triangulated points which lie in front of the two estimated cameras.
- Throws:
InitialCamerasEstimationFailedException
- if estimation of cameras fails for some reason, typically due to numerical instabilities.IllegalArgumentException
- if provided lists of left and right points don't have the same size.
-
generateInitialMetricCamerasFromEssentialMatrix
public static int generateInitialMetricCamerasFromEssentialMatrix(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, CorrectorType correctorType, com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) throws InitialCamerasEstimationFailedException Generates a pair of metric cameras (up to an arbitrary space) by computing the essential matrix from provided fundamental matrix and intrinsic parameters of left and right cameras, and choosing the best pair of camera pose and translation that yields the largest number of triangulated points laying in front of both of the estimated cameras.- Parameters:
fundamentalMatrix
- fundamental matrix relating both left and right views.leftIntrinsic
- intrinsic parameters to be set on left view. This can be used when cameras have been previously calibrated.rightIntrinsic
- intrinsic parameters to be set on right view. This can be used when cameras have been previously calibrated.leftPoints
- points on left view matched with points on right view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.rightPoints
- points on right view matched with points on left view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.correctorType
- corrector type to be used to correct 2D points, so they follow the epipolar geometry defined by provided fundamental matrix so that error on triangulated points is reduced. If null, no corrector will be used.leftCamera
- instance where estimated left camera will be stored.rightCamera
- instance where estimated right camera will be stored.triangulatedPoints
- instance where triangulated 3D points will be stored or null if triangulated points don't need to be kept.validTriangulatedPoints
- instance which indicates which triangulated 3D points are considered valid because they lie in front of both cameras or null if such data doesn't need to be kept.- Returns:
- number of valid triangulated points which lie in front of the two estimated cameras.
- Throws:
InitialCamerasEstimationFailedException
- if estimation of cameras fails for some reason, typically due to numerical instabilities.IllegalArgumentException
- if provided lists of left and right points don't have the same size.
-
internalSetLeftAndRightPoints
private void internalSetLeftAndRightPoints(List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints) Internal method to set matched 2D points on left and right views. This method does not check whether the estimator is locked or not, only ensures that provided lists have the same size.- Parameters:
leftPoints
- matched 2D points on left view.rightPoints
- matched 2D points on right view.- Throws:
IllegalArgumentException
- if provided lists don't have the same size.
-
updateBestSolutionData
private static void updateBestSolutionData(com.irurueta.geometry.PinholeCamera leftCamera, com.irurueta.geometry.PinholeCamera rightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints, com.irurueta.geometry.PinholeCamera attemptLeftCamera, com.irurueta.geometry.PinholeCamera attemptRightCamera, List<com.irurueta.geometry.Point3D> attemptTriangulatedPoints, BitSet attemptValidTriangulatedPoints) throws InitialCamerasEstimationFailedException Updates data for best solution found so far.- Parameters:
leftCamera
- instance where best found left camera will be stored.rightCamera
- instance where best found right camera will be stored.triangulatedPoints
- instance where triangulated points for best found solution will be stored or null if points don't need to be kept.validTriangulatedPoints
- instance where valid triangulated points for best found solution will be stored or null if such data doesn't need to be kept.attemptLeftCamera
- estimated left camera to be copied into the best solution.attemptRightCamera
- estimated right camera to be copied into the best solution.attemptTriangulatedPoints
- triangulated points to be copied into the best solution, or null if nothing needs to be copied.attemptValidTriangulatedPoints
- valid triangulated points to be copied into the best solution, or null if nothing needs to be copied.- Throws:
InitialCamerasEstimationFailedException
- if something fails.
-
computeCamerasAndTriangulation
private static int computeCamerasAndTriangulation(com.irurueta.geometry.Rotation3D rotation, com.irurueta.geometry.Point2D translation, com.irurueta.geometry.PinholeCameraIntrinsicParameters leftIntrinsic, com.irurueta.geometry.PinholeCameraIntrinsicParameters rightIntrinsic, List<com.irurueta.geometry.Point2D> leftPoints, List<com.irurueta.geometry.Point2D> rightPoints, com.irurueta.geometry.PinholeCamera estimatedLeftCamera, com.irurueta.geometry.PinholeCamera estimatedRightCamera, List<com.irurueta.geometry.Point3D> triangulatedPoints, BitSet validTriangulatedPoints) throws com.irurueta.algebra.WrongSizeException, com.irurueta.geometry.CameraException, com.irurueta.geometry.estimators.LockedException, com.irurueta.geometry.estimators.NotReadyException, Point3DTriangulationException Computes a pair of cameras for provided rotation and translation using provided intrinsic parameters. This method also triangulates proved matched 2D points and determines how many of them lie in front of both estimated cameras.- Parameters:
rotation
- rotation between estimated left and right cameras.translation
- translation between estimated left and right cameras.leftIntrinsic
- intrinsic parameters to set on estimated left camera.rightIntrinsic
- intrinsic parameters to set on estimated right camera.leftPoints
- points on left view matched with points on right view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.rightPoints
- points on right view matched with points on left view, so they can be triangulated using estimated cameras. Both lists of points must have the same size.estimatedLeftCamera
- instance where estimated left camera will be stored.estimatedRightCamera
- instance where estimated right camera will be stored.triangulatedPoints
- instance where triangulated 3D points will be stored or null if triangulated points don't need to be kept.validTriangulatedPoints
- instance which indicates which triangulated 3D points are considered valid because they lie in front of both cameras or null if such data doesn't need to be kept.- Returns:
- number of valid triangulated points which lie in front of the two estimated cameras.
- Throws:
com.irurueta.algebra.WrongSizeException
- never occurs.com.irurueta.geometry.CameraException
- if any of the estimated cameras become numerically unstable.com.irurueta.geometry.estimators.LockedException
- never occurs.com.irurueta.geometry.estimators.NotReadyException
- never occurs.Point3DTriangulationException
- if points cannot be triangulated because of numerical instabilities.
-