Class ProjectiveStructureByFactorization

java.lang.Object
boofcv.alg.geo.structure.ProjectiveStructureByFactorization

public class ProjectiveStructureByFactorization extends Object
Performs projective reconstruction via factorization. For every view all points are observed. The algorithm works by iteratively estimating the depth of each point in every view and this results in better and better estimates of the projective camera matrices and the points being found. An initial estimate of feature depth can be provided. Unfortunately, there is no grantee of this method converging to a valid solution.
 [ λ[1,1]*x[1,1] , λ[1,2]*x[1,2] , ... , λ[1,M]*x[1,M] ]  = [ P[1] ] * [X[1], X[2], ... , X[N]
 [ λ[2,1]*x[1,1] , λ[2,2]*x[1,2] , ... , λ[2,M]*x[2,M] ]  = [ P[2] ]
 [                                 ...               ]  = [ ... ]
 [ λ[N,1]*x[1,1] , λ[N,2]*x[1,2] , ... , λ[N,M]*x[N,M] ]  = [ P[M] ]
 
where λ is the depth, x is homogenous pixel coordinate, P is 3x4 projective, X is 3D feature location in world coordinate system. Procedure:
  1. Call initialize(int, int) and specify the system's size
  2. Set initial pixel depths
  3. Set pixel observations for each view
  4. Call process()
  5. Get results with getFeature3D(int, georegression.struct.point.Point4D_F64) and getCameraMatrix(int, org.ejml.data.DMatrixRMaj)

Internally depth and pixel values are scaled so that they are close to unity then undo for output. This ensures better approximation of errors and has other desirable numerical properties.

[1] Page 444 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003

  • Constructor Details

    • ProjectiveStructureByFactorization

      public ProjectiveStructureByFactorization()
  • Method Details

    • initialize

      public void initialize(int numFeatures, int numViews)
      Initializes internal data structures. Must be called first
      Parameters:
      numFeatures - Number of features
      numViews - Number of views
    • setPixels

      public void setPixels(int view, List<Point2D_F64> pixelsInView)
      Sets pixel observations for a paricular view
      Parameters:
      view - the view
      pixelsInView - list of 2D pixel observations
    • setAllDepths

      public void setAllDepths(double value)
      Sets all depths to an initial value
    • setDepths

      public void setDepths(int view, double[] featureDepths)
      Sets depths for a particular value to the values in the passed in array
    • setDepthsFrom3D

      public void setDepthsFrom3D(int view, List<Point3D_F64> locations)
      Assigns depth to the z value of all the features in the list. Features must be in the coordinate system of the view for this to be correct
      Parameters:
      view - which view is features are in
      locations - Location of features in the view's reference frame
    • process

      public boolean process()
      Performs iteration to find camera matrices and feature locations in world frame
      Returns:
      true if no exception was thrown. Does not mean it converged to a valid solution
    • getCameraMatrix

      public void getCameraMatrix(int view, DMatrixRMaj cameraMatrix)
      Used to get found camera matrix for a view
      Parameters:
      view - Which view
      cameraMatrix - storage for 3x4 projective camera matrix
    • getFeature3D

      public void getFeature3D(int feature, Point4D_F64 out)
      Returns location of 3D feature for a view
      Parameters:
      feature - Index of feature to retrieve
      out - (Output) Storage for 3D feature. homogenous coordinates
    • assignValuesToA

      public void assignValuesToA(DMatrixRMaj A)
      A[:,0] = depth*[x,y,1]'
    • normalizeDepths

      public void normalizeDepths(DMatrixRMaj depths)

      Rescale A so that its rows and columns have a value of approximately 1. This is done to try to get everything set to unity for desirable numerical properties

      (α β λ) x = (αP)(βX)
    • getMaxIterations

      public int getMaxIterations()
    • setMaxIterations

      public void setMaxIterations(int maxIterations)
    • getMinimumChangeTol

      public double getMinimumChangeTol()
    • setMinimumChangeTol

      public void setMinimumChangeTol(double minimumChangeTol)