public GeometricResult solve ( ) { if ( cameras . size < minimumProjectives ) throw new IllegalArgumentException ( "You need at least " + minimumProjectives + " motions" ) ; int N = cameras . size ; DMatrixRMaj L = new DMatrixRMaj ( N * eqs , 10 ) ; // Convert constraints into a (N*eqs) by 10 matrix. Null space is Q constructMatrix ( L ) ; // Compute the SVD for its null space if ( ! svd . decompose ( L ) ) { return GeometricResult . SOLVE_FAILED ; } // Examine the null space to find the values of Q extractSolutionForQ ( Q ) ; // determine if the solution is good by looking at two smallest singular values // If there isn't a steep drop it either isn't singular or more there is more than 1 singular value double sv [ ] = svd . getSingularValues ( ) ; Arrays . sort ( sv ) ; if ( singularThreshold * sv [ 1 ] <= sv [ 0 ] ) { // System.out.println("ratio = "+(sv[0]/sv[1])); return GeometricResult . GEOMETRY_POOR ; } // Enforce constraints and solve for each view if ( ! MultiViewOps . enforceAbsoluteQuadraticConstraints ( Q , true , zeroSkew ) ) { return GeometricResult . SOLVE_FAILED ; } computeSolutions ( Q ) ; if ( solutions . size ( ) != N ) { return GeometricResult . SOLUTION_NAN ; } else { return GeometricResult . SUCCESS ; } }
Solve for camera calibration . A sanity check is performed to ensure that a valid calibration is found . All values must be countable numbers and the focal lengths must be positive numbers .