public static DMatrixRMaj robustFundamental ( List < AssociatedPair > matches , List < AssociatedPair > inliers , double inlierThreshold ) { ConfigRansac configRansac = new ConfigRansac ( ) ; configRansac . inlierThreshold = inlierThreshold ; configRansac . maxIterations = 1000 ; ConfigFundamental configFundamental = new ConfigFundamental ( ) ; configFundamental . which = EnumFundamental . LINEAR_7 ; configFundamental . numResolve = 2 ; configFundamental . errorModel = ConfigFundamental . ErrorModel . GEOMETRIC ; // geometric error is the most accurate error metric, but also the slowest to compute. See how the // results change if you switch to sampson and how much faster it is. You also should adjust // the inlier threshold. ModelMatcher < DMatrixRMaj , AssociatedPair > ransac = FactoryMultiViewRobust . fundamentalRansac ( configFundamental , configRansac ) ; // Estimate the fundamental matrix while removing outliers if ( ! ransac . process ( matches ) ) throw new IllegalArgumentException ( "Failed" ) ; // save the set of features that were used to compute the fundamental matrix inliers . addAll ( ransac . getMatchSet ( ) ) ; // Improve the estimate of the fundamental matrix using non-linear optimization DMatrixRMaj F = new DMatrixRMaj ( 3 , 3 ) ; ModelFitter < DMatrixRMaj , AssociatedPair > refine = FactoryMultiView . fundamentalRefine ( 1e-8 , 400 , EpipolarError . SAMPSON ) ; if ( ! refine . fitModel ( inliers , ransac . getModelParameters ( ) , F ) ) throw new IllegalArgumentException ( "Failed" ) ; // Return the solution return F ; }
Given a set of noisy observations compute the Fundamental matrix while removing the noise .