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 Details

    • NUMBER_OF_VIEWS

      public static final int NUMBER_OF_VIEWS
      Number of views.
      See Also:
    • estimatedFundamentalMatrix

      protected EstimatedFundamentalMatrix estimatedFundamentalMatrix
      Estimated fundamental matrix.
    • estimatedCamera1

      protected EstimatedCamera estimatedCamera1
      Estimated first camera.
    • estimatedCamera2

      protected EstimatedCamera estimatedCamera2
      Estimated second camera.
    • reconstructedPoints

      protected List<ReconstructedPoint3D> reconstructedPoints
      Reconstructed 3D points.
    • configuration

      protected C extends BaseTwoViewsSparseReconstructorConfiguration<C> configuration
      Configuration for this re-constructor.
    • listener

      protected L extends BaseTwoViewsSparseReconstructorListener<R> 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 failed
      Indicates whether reconstruction has failed or not.
    • running

      protected volatile boolean running
      Indicates whether reconstruction is running or not.
    • cancelled

      private volatile boolean cancelled
      Indicates whether reconstruction has been cancelled or not.
    • viewCount

      private int viewCount
      Counter of number of processed views.
    • finished

      private boolean finished
      Indicates whether reconstruction has finished or not.
    • firstViewSamples

      private List<Sample2D> firstViewSamples
      Samples on first view.
    • currentViewSamples

      private List<Sample2D> currentViewSamples
      Samples on last processed view (i.e. current view).
    • matches

      private final List<MatchedSamples> matches
      Matches between first and current view.
    • firstViewId

      private int firstViewId
      ID of first view.
  • Constructor Details

    • BaseTwoViewsSparseReconstructor

      protected BaseTwoViewsSparseReconstructor(C configuration, L listener)
      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

      public C 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

      public EstimatedFundamentalMatrix getEstimatedFundamentalMatrix()
      Gets estimated fundamental matrix.
      Returns:
      estimated fundamental matrix.
    • getEstimatedCamera1

      public EstimatedCamera getEstimatedCamera1()
      Gets estimated first camera.
      Returns:
      estimated first camera.
    • getEstimatedCamera2

      public EstimatedCamera getEstimatedCamera2()
      Gets estimated second camera.
      Returns:
      estimated second camera.
    • getReconstructedPoints

      public List<ReconstructedPoint3D> 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 of start() 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

      private boolean hasEnoughSamples(List<Sample2D> samples)
      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

      private boolean hasEnoughMatches(List<MatchedSamples> matches)
      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

      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.
      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.