Package com.irurueta.ar.sfm
Class BaseTwoViewsSparseReconstructor<C extends BaseTwoViewsSparseReconstructorConfiguration<C>,R extends BaseTwoViewsSparseReconstructor<C,R,L>,L extends BaseTwoViewsSparseReconstructorListener<R>>
java.lang.Object
com.irurueta.ar.sfm.BaseTwoViewsSparseReconstructor<C,R,L>
- Type Parameters:
C
- type of configuration.R
- type of re-constructor.L
- type of listener.
- Direct Known Subclasses:
BaseSlamTwoViewsSparseReconstructor
,KnownBaselineTwoViewsSparseReconstructor
,TwoViewsSparseReconstructor
public abstract class BaseTwoViewsSparseReconstructor<C extends BaseTwoViewsSparseReconstructorConfiguration<C>,R extends BaseTwoViewsSparseReconstructor<C,R,L>,L extends BaseTwoViewsSparseReconstructorListener<R>>
extends Object
Base class in charge of estimating cameras and 3D reconstructed points from
sparse image point correspondences in two views.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Indicates whether reconstruction has been cancelled or not.protected C
Configuration for this re-constructor.Samples on last processed view (i.e. current view).protected EstimatedCamera
Estimated first camera.protected EstimatedCamera
Estimated second camera.protected EstimatedFundamentalMatrix
Estimated fundamental matrix.protected boolean
Indicates whether reconstruction has failed or not.private boolean
Indicates whether reconstruction has finished or not.private int
ID of first view.Samples on first view.protected L
Listener in charge of handling events such as when reconstruction starts, ends, when certain data is needed or when estimation of data has been computed.private final List<MatchedSamples>
Matches between first and current view.static final int
Number of views.protected List<ReconstructedPoint3D>
Reconstructed 3D points.protected boolean
Indicates whether reconstruction is running or not.private int
Counter of number of processed views. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseTwoViewsSparseReconstructor
(C configuration, L listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels reconstruction.private boolean
estimateFundamentalMatrix
(List<MatchedSamples> matches, int viewId1, int viewId2) Estimates fundamental matrix for provided matches, when 3D points lay in a general non-degenerate 3D configuration.private boolean
Estimates initial cameras and reconstructed points.private boolean
Estimates initial cameras and reconstructed points using the Dual Absolute Quadric.private boolean
Estimates initial cameras and reconstructed points using the Dual Absolute Quadric to estimate intrinsic parameters and then use those intrinsic parameters with the essential matrix.private boolean
Estimates initial cameras and reconstructed points using Dual Image of Absolute Conic.private boolean
Estimates initial cameras and reconstructed points using the essential matrix and provided intrinsic parameters that must have been set during offline calibration.private boolean
estimateInitialCamerasAndPointsEssential
(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic2) Estimates initial cameras and reconstructed points using the essential matrix and provided intrinsic parameters that must have been set during offline calibration.private boolean
estimatePlanarFundamentalMatrix
(List<MatchedSamples> matches, int viewId1, int viewId2) Estimates fundamental matrix for provided matches, when 3D points lay in a planar 3D scene.private void
fixFundamentalMatrix
(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicZeroPrincipalPoint1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicZeroPrincipalPoint2, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicPrincipalPoint1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicPrincipalPoint2) Fixes fundamental matrix to account for principal point different from zero when using DAQ estimation.Gets configuration for this re-constructor.Gets estimated first camera.Gets estimated second camera.Gets estimated fundamental matrix.Gets listener in charge of handling events such as when reconstruction starts, ends, when certain data is needed or when estimation of data has been computed.Gets reconstructed 3D points.int
Gets counter of number of processed views.private boolean
hasEnoughMatches
(List<MatchedSamples> matches) Indicates whether there are enough matches to estimate a fundamental matrix.private boolean
hasEnoughSamples
(List<Sample2D> samples) Indicates whether there are enough samples to estimate a fundamental matrix.private boolean
hasEnoughSamplesOrMatches
(int count) Indicates whether there are enough matches or samples to estimate a fundamental matrix.boolean
Indicates whether reconstruction has failed or not.boolean
Indicates whether reconstruction has been cancelled or not.boolean
Indicates whether the reconstruction has finished.boolean
Indicates whether reconstruction is running or not.protected abstract boolean
Called when processing one frame is successfully finished.boolean
Process one view of all the available data during the reconstruction.void
reset()
Resets this instance so that a reconstruction can be started from the beginning without cancelling current one.void
start()
Starts reconstruction of all available data to reconstruct the whole scene.
-
Field Details
-
NUMBER_OF_VIEWS
public static final int NUMBER_OF_VIEWSNumber of views.- See Also:
-
estimatedFundamentalMatrix
Estimated fundamental matrix. -
estimatedCamera1
Estimated first camera. -
estimatedCamera2
Estimated second camera. -
reconstructedPoints
Reconstructed 3D points. -
configuration
Configuration for this re-constructor. -
listener
Listener in charge of handling events such as when reconstruction starts, ends, when certain data is needed or when estimation of data has been computed. -
failed
protected volatile boolean failedIndicates whether reconstruction has failed or not. -
running
protected volatile boolean runningIndicates whether reconstruction is running or not. -
cancelled
private volatile boolean cancelledIndicates whether reconstruction has been cancelled or not. -
viewCount
private int viewCountCounter of number of processed views. -
finished
private boolean finishedIndicates whether reconstruction has finished or not. -
firstViewSamples
Samples on first view. -
currentViewSamples
Samples on last processed view (i.e. current view). -
matches
Matches between first and current view. -
firstViewId
private int firstViewIdID of first view.
-
-
Constructor Details
-
BaseTwoViewsSparseReconstructor
Constructor.- Parameters:
configuration
- configuration for this re-constructor.listener
- listener in charge of handling events.- Throws:
NullPointerException
- if listener or configuration is not provided.
-
-
Method Details
-
getConfiguration
Gets configuration for this re-constructor.- Returns:
- configuration for this re-constructor.
-
getListener
Gets listener in charge of handling events such as when reconstruction starts, ends, when certain data is needed or when estimation of data has been computed.- Returns:
- listener in charge of handling events.
-
isRunning
public boolean isRunning()Indicates whether reconstruction is running or not.- Returns:
- true if reconstruction is running, false if reconstruction has stopped for any reason.
-
isCancelled
public boolean isCancelled()Indicates whether reconstruction has been cancelled or not.- Returns:
- true if reconstruction has been cancelled, false otherwise.
-
hasFailed
public boolean hasFailed()Indicates whether reconstruction has failed or not.- Returns:
- true if reconstruction has failed, false otherwise.
-
isFinished
public boolean isFinished()Indicates whether the reconstruction has finished.- Returns:
- true if reconstruction has finished, false otherwise.
-
getViewCount
public int getViewCount()Gets counter of number of processed views.- Returns:
- counter of number of processed views.
-
getEstimatedFundamentalMatrix
Gets estimated fundamental matrix.- Returns:
- estimated fundamental matrix.
-
getEstimatedCamera1
Gets estimated first camera.- Returns:
- estimated first camera.
-
getEstimatedCamera2
Gets estimated second camera.- Returns:
- estimated second camera.
-
getReconstructedPoints
Gets reconstructed 3D points.- Returns:
- reconstructed 3D points.
-
processOneView
public boolean processOneView()Process one view of all the available data during the reconstruction. This method can be called multiple times instead ofstart()
to build the reconstruction step by step, one view at a time.- Returns:
- true if more views can be processed, false when reconstruction has finished.
-
start
public void start()Starts reconstruction of all available data to reconstruct the whole scene. If reconstruction has already started and is running, calling this method has no effect. -
cancel
public void cancel()Cancels reconstruction. If reconstruction has already been cancelled, calling this method has no effect. -
reset
public void reset()Resets this instance so that a reconstruction can be started from the beginning without cancelling current one. -
postProcessOne
protected abstract boolean postProcessOne()Called when processing one frame is successfully finished. This can be done to estimate scale on those implementations where scale can be measured or is already known.- Returns:
- true if post-processing succeeded, false otherwise.
-
hasEnoughSamples
Indicates whether there are enough samples to estimate a fundamental matrix.- Parameters:
samples
- samples to check.- Returns:
- true if there are enough samples, false otherwise.
-
hasEnoughMatches
Indicates whether there are enough matches to estimate a fundamental matrix.- Parameters:
matches
- matches to check.- Returns:
- true if there are enough matches, false otherwise.
-
hasEnoughSamplesOrMatches
private boolean hasEnoughSamplesOrMatches(int count) Indicates whether there are enough matches or samples to estimate a fundamental matrix.- Parameters:
count
- number of matches or samples.- Returns:
- true if there are enough matches or samples, false otherwise.
-
estimateFundamentalMatrix
Estimates fundamental matrix for provided matches, when 3D points lay in a general non-degenerate 3D configuration.- Parameters:
matches
- pairs of matches to find fundamental matrix.viewId1
- id of first view.viewId2
- id of second view.- Returns:
- true if estimation succeeded, false otherwise.
-
estimatePlanarFundamentalMatrix
private boolean estimatePlanarFundamentalMatrix(List<MatchedSamples> matches, int viewId1, int viewId2) Estimates fundamental matrix for provided matches, when 3D points lay in a planar 3D scene.- Parameters:
matches
- pairs of matches to find fundamental matrix.viewId1
- id of first view.viewId2
- id of second view.- Returns:
- true if estimation succeeded, false otherwise.
-
estimateInitialCamerasAndPoints
private boolean estimateInitialCamerasAndPoints()Estimates initial cameras and reconstructed points.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
estimateInitialCamerasAndPointsDAQAndEssential
private boolean estimateInitialCamerasAndPointsDAQAndEssential()Estimates initial cameras and reconstructed points using the Dual Absolute Quadric to estimate intrinsic parameters and then use those intrinsic parameters with the essential matrix.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
estimateInitialCamerasAndPointsDAQ
private boolean estimateInitialCamerasAndPointsDAQ()Estimates initial cameras and reconstructed points using the Dual Absolute Quadric.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
estimateInitialCamerasAndPointsDIAC
private boolean estimateInitialCamerasAndPointsDIAC()Estimates initial cameras and reconstructed points using Dual Image of Absolute Conic.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
estimateInitialCamerasAndPointsEssential
private boolean estimateInitialCamerasAndPointsEssential()Estimates initial cameras and reconstructed points using the essential matrix and provided intrinsic parameters that must have been set during offline calibration.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
estimateInitialCamerasAndPointsEssential
private boolean estimateInitialCamerasAndPointsEssential(com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsic2) Estimates initial cameras and reconstructed points using the essential matrix and provided intrinsic parameters that must have been set during offline calibration.- Parameters:
intrinsic1
- intrinsic parameters of 1st camera.intrinsic2
- intrinsic parameters of 2nd camera.- Returns:
- true if cameras and points could be estimated, false if something failed.
-
fixFundamentalMatrix
private void fixFundamentalMatrix(FundamentalMatrix fundamentalMatrix, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicZeroPrincipalPoint1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicZeroPrincipalPoint2, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicPrincipalPoint1, com.irurueta.geometry.PinholeCameraIntrinsicParameters intrinsicPrincipalPoint2) throws EpipolarException, com.irurueta.geometry.estimators.NotReadyException Fixes fundamental matrix to account for principal point different from zero when using DAQ estimation.- Parameters:
fundamentalMatrix
- fundamental matrix to be fixed.intrinsicZeroPrincipalPoint1
- intrinsic parameters of camera 1 assuming zero principal point.intrinsicZeroPrincipalPoint2
- intrinsic parameters of camera 2 assuming zero principal point.intrinsicPrincipalPoint1
- intrinsic parameters of camera 1 using proper principal point.intrinsicPrincipalPoint2
- intrinsic parameters of camera 2 using proper principal point.- Throws:
EpipolarException
- if something fails.com.irurueta.geometry.estimators.NotReadyException
- never happens.
-