double scoreForTriangulation ( Motion motion ) { DMatrixRMaj H = new DMatrixRMaj ( 3 , 3 ) ; View viewA = motion . viewSrc ; View viewB = motion . viewDst ; // Compute initial estimate for H pairs . reset ( ) ; for ( int i = 0 ; i < motion . associated . size ( ) ; i ++ ) { AssociatedIndex ai = motion . associated . get ( i ) ; pairs . grow ( ) . set ( viewA . observationPixels . get ( ai . src ) , viewB . observationPixels . get ( ai . dst ) ) ; } if ( ! computeH . process ( pairs . toList ( ) , H ) ) return - 1 ; // remove bias from linear model if ( ! refineH . fitModel ( pairs . toList ( ) , H , H ) ) return - 1 ; // Compute 50% errors to avoid bias from outliers MultiViewOps . errorsHomographySymm ( pairs . toList ( ) , H , null , errors ) ; errors . sort ( ) ; return errors . getFraction ( 0.5 ) * Math . max ( 5 , pairs . size - 20 ) ; }
Compute score to decide which motion to initialize structure from . A homography is fit to the observations and the error compute . The homography should be a poor fit if the scene had 3D structure . The 50% homography error is then scaled by the number of pairs to bias the score good matches