protected boolean connectViews ( PairwiseImageGraph . View viewA , PairwiseImageGraph . View viewB , FastQueue < AssociatedIndex > matches ) { // Estimate fundamental/essential with RANSAC PairwiseImageGraph . Motion edge = new PairwiseImageGraph . Motion ( ) ; int inliersEpipolar ; CameraPinhole pinhole0 = viewA . camera . pinhole ; CameraPinhole pinhole1 = viewB . camera . pinhole ; if ( pinhole0 != null && pinhole1 != null ) { // Fully calibrated camera pair ransacEssential . setIntrinsic ( 0 , pinhole0 ) ; ransacEssential . setIntrinsic ( 1 , pinhole1 ) ; if ( ! fitEpipolar ( matches , viewA . observationNorm . toList ( ) , viewB . observationNorm . toList ( ) , ransacEssential , edge ) ) { if ( verbose != null && verboseLevel >= 1 ) { verbose . println ( " fit essential failed" ) ; } return false ; } edge . metric = true ; inliersEpipolar = ransacEssential . getMatchSet ( ) . size ( ) ; edge . F . set ( ransacEssential . getModelParameters ( ) ) ; } else if ( fitEpipolar ( matches , viewA . observationPixels . toList ( ) , viewB . observationPixels . toList ( ) , ransacFundamental , edge ) ) { // transform is only known up to a projective transform edge . metric = false ; inliersEpipolar = ransacFundamental . getMatchSet ( ) . size ( ) ; edge . F . set ( ransacFundamental . getModelParameters ( ) ) ; } else { if ( verbose != null && verboseLevel >= 1 ) { verbose . println ( " fit fundamental failed" ) ; } return false ; } if ( inliersEpipolar < MIN_FEATURE_ASSOCIATED ) { if ( verbose != null && verboseLevel >= 1 ) { verbose . println ( " too too few inliers. " + inliersEpipolar + " min=" + MIN_FEATURE_ASSOCIATED + " obsA=" + viewA . observationNorm . size + " obsB=" + viewB . observationNorm . size ) ; } return false ; } // If only a very small number of features are associated do not consider the view double fractionA = inliersEpipolar / ( double ) viewA . descriptions . size ; double fractionB = inliersEpipolar / ( double ) viewB . descriptions . size ; if ( fractionA < MIN_ASSOCIATE_FRACTION | fractionB < MIN_ASSOCIATE_FRACTION ) return false ; // If the geometry is good for triangulation this number will be lower edge . viewSrc = viewA ; edge . viewDst = viewB ; edge . index = graph . edges . size ( ) ; viewA . connections . add ( edge ) ; viewB . connections . add ( edge ) ; graph . edges . add ( edge ) ; return true ; }
Associate features between the two views . Then compute a homography and essential matrix using LSMed . Add features to the edge if they an inlier in essential . Save fit score of homography vs essential .