public Se3_F64 estimateOutliers ( List < Point2D3D > observations ) { // We can no longer trust that each point is a real observation. Let's use RANSAC to separate the points // You will need to tune the number of iterations and inlier threshold!!! ModelMatcherMultiview < Se3_F64 , Point2D3D > ransac = FactoryMultiViewRobust . pnpRansac ( new ConfigPnP ( ) , new ConfigRansac ( 300 , 1.0 ) ) ; ransac . setIntrinsic ( 0 , intrinsic ) ; // Observations must be in normalized image coordinates! See javadoc of pnpRansac if ( ! ransac . process ( observations ) ) throw new RuntimeException ( "Probably got bad input data with NaN inside of it" ) ; System . out . println ( "Inlier size " + ransac . getMatchSet ( ) . size ( ) ) ; Se3_F64 worldToCamera = ransac . getModelParameters ( ) ; // You will most likely want to refine this solution too. Can make a difference with real world data RefinePnP refine = FactoryMultiView . pnpRefine ( 1e-8 , 200 ) ; Se3_F64 refinedWorldToCamera = new Se3_F64 ( ) ; // notice that only the match set was passed in if ( ! refine . fitModel ( ransac . getMatchSet ( ) , worldToCamera , refinedWorldToCamera ) ) throw new RuntimeException ( "Refined failed! Input probably bad..." ) ; return refinedWorldToCamera ; }
Uses robust techniques to remove outliers