Class WeightedHomogeneousSinglePoint3DTriangulator

java.lang.Object
com.irurueta.ar.sfm.SinglePoint3DTriangulator
com.irurueta.ar.sfm.WeightedHomogeneousSinglePoint3DTriangulator

public class WeightedHomogeneousSinglePoint3DTriangulator extends SinglePoint3DTriangulator
Triangulates matched 2D points into a single 3D one by using 2D point correspondences on different views along with the corresponding cameras on each of those views by finding a weighted solution to homogeneous systems of equations. Each equation on the linear system of equations is weighted using provided weight for each point and camera correspondence, so that some equations can be considered more important than others if we are more confident on some measures than others.
  • Field Details

    • DEFAULT_MAX_CORRESPONDENCES

      public static final int DEFAULT_MAX_CORRESPONDENCES
      Default number of correspondences to be weighted and taken into account. If more correspondences are provided, they are ignored to avoid numerical inaccuracies.
      See Also:
    • DEFAULT_SORT_WEIGHTS

      public static final boolean DEFAULT_SORT_WEIGHTS
      Indicates if weights are sorted by default so that largest weighted correspondences are used first.
      See Also:
    • maxCorrespondences

      private int maxCorrespondences
      Maximum number of correspondences to be weighted and taken into account.
    • sortWeights

      private boolean sortWeights
      Indicates if weights are sorted by default so that largest weighted correspondences are used first.
    • weights

      private double[] weights
      Array containing weights for all correspondences.
  • Constructor Details

    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator()
      Constructor.
    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras)
      Constructor.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - camera for each view where 2D points are represented.
      Throws:
      IllegalArgumentException - if provided lists don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.
    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, double[] weights)
      Constructor.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - camera for each view where 2D points are represented.
      weights - weights assigned to each view.
      Throws:
      IllegalArgumentException - if provided lists or weights don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.
    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator(SinglePoint3DTriangulatorListener listener)
      Constructor.
      Parameters:
      listener - listener to notify events generated by instances of this class.
    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, SinglePoint3DTriangulatorListener listener)
      Constructor.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - cameras for each view where 2D points are represented.
      listener - listener to notify events generated by instances of this class.
      Throws:
      IllegalArgumentException - if provided lists don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.
    • WeightedHomogeneousSinglePoint3DTriangulator

      public WeightedHomogeneousSinglePoint3DTriangulator(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, double[] weights, SinglePoint3DTriangulatorListener listener)
      Constructor.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - camera for each view where 2D points are represented.
      weights - weights assigned to each view.
      listener - listener to notify events generated by instances of this class.
      Throws:
      IllegalArgumentException - if provided lists or weights don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.
  • Method Details

    • getWeights

      public double[] getWeights()
      Returns weights assigned to each view. The larger a weight is the more reliable a view is considered and equations to triangulate a 3D point will be take precedence over other views when estimating an averaged solution.
      Returns:
      weights assigned to each view.
    • setPointsCamerasAndWeights

      public void setPointsCamerasAndWeights(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, double[] weights) throws com.irurueta.geometry.estimators.LockedException
      Sets list of matched 2D points for each view and their corresponding cameras used to project them along with their weights.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - cameras for each view where 2D points are represented.
      weights - weights assigned to each view.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
      IllegalArgumentException - if provided lists don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.
    • isReady

      public boolean isReady()
      Indicates whether this instance is ready to start the triangulation. An instance is ready when both lists of 2D points and cameras are provided, both lists have the same length, at least data for 2 views is provided and the corresponding weights are also provided.
      Overrides:
      isReady in class SinglePoint3DTriangulator
      Returns:
      true if this instance is ready, false otherwise.
    • areValidPointsCamerasAndWeights

      public static boolean areValidPointsCamerasAndWeights(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, double[] weights)
      Indicates whether provided points, cameras and weights are valid to start the triangulation. In order to triangulate points, at least two cameras and their corresponding 2 matched 2D points are required along with weights for each view. If more views are provided, an averaged solution can be found.
      Parameters:
      points2D - list of matched points on each view.
      cameras - cameras for each view where 2D points are represented.
      weights - weights assigned to each view.
      Returns:
      true if data is enough to start triangulation, false otherwise.
    • getMaxCorrespondences

      public int getMaxCorrespondences()
      Returns maximum number of correspondences to be weighted and taken into account.
      Returns:
      maximum number of correspondences to be weighted.
    • setMaxCorrespondences

      public void setMaxCorrespondences(int maxCorrespondences) throws com.irurueta.geometry.estimators.LockedException
      Sets maximum number of correspondences to be weighted and taken into account.
      Parameters:
      maxCorrespondences - maximum number of correspondences to be weighted.
      Throws:
      IllegalArgumentException - if provided value is less than the minimum required number of views, which is 2.
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
    • isSortWeightsEnabled

      public boolean isSortWeightsEnabled()
      Indicates if weights are sorted by so that largest weighted correspondences are used first.
      Returns:
      true if weights are sorted, false otherwise.
    • setSortWeightsEnabled

      public void setSortWeightsEnabled(boolean sortWeights) throws com.irurueta.geometry.estimators.LockedException
      Specifies whether weights are sorted by so that largest weighted correspondences are used first.
      Parameters:
      sortWeights - true if weights are sorted, false otherwise.
      Throws:
      com.irurueta.geometry.estimators.LockedException - if this instance is locked.
    • getType

      public Point3DTriangulatorType getType()
      Returns type of triangulator.
      Specified by:
      getType in class SinglePoint3DTriangulator
      Returns:
      type of triangulator.
    • triangulate

      protected void triangulate(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, com.irurueta.geometry.Point3D result) throws Point3DTriangulationException
      Internal method to triangulate provided matched 2D points being projected by each corresponding camera into a single 3D point. At least 2 matched 2D points and their corresponding 2 cameras are required to compute triangulation. If more views are provided, an averaged solution is found. This method does not check whether instance is locked or ready.
      Specified by:
      triangulate in class SinglePoint3DTriangulator
      Parameters:
      points2D - matched 2D points. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - list of cameras associated to the matched 2D point on the same position as the camera on the list.
      result - instance where triangulated 3D point is stored.
      Throws:
      Point3DTriangulationException - if triangulation fails for some other reason (i.e. degenerate geometry, numerical instabilities, etc.).
    • internalSetPointsCamerasAndWeights

      private void internalSetPointsCamerasAndWeights(List<com.irurueta.geometry.Point2D> points2D, List<com.irurueta.geometry.PinholeCamera> cameras, double[] weights)
      Internal method to set list of matched 2D points for each view and their corresponding cameras used to project them along with their weights. This method does not check whether instance is locked.
      Parameters:
      points2D - list of matched 2D points on each view. Each point in the list is assumed to be projected by the corresponding camera in the list.
      cameras - cameras for each view where 2D points are represented.
      weights - weights assigned to each view.
      Throws:
      IllegalArgumentException - if provided lists don't have the same length or their length is less than 2 views, which is the minimum required to compute triangulation.