public static < I extends ImageBase < I > , IT extends InvertibleTransform > ImageMotion2D < I , IT > createMotion2D ( int ransacIterations , double inlierThreshold , int outlierPrune , int absoluteMinimumTracks , double respawnTrackFraction , double respawnCoverageFraction , boolean refineEstimate , PointTracker < I > tracker , IT motionModel ) { ModelManager < IT > manager ; ModelGenerator < IT , AssociatedPair > fitter ; DistanceFromModel < IT , AssociatedPair > distance ; ModelFitter < IT , AssociatedPair > modelRefiner = null ; if ( motionModel instanceof Homography2D_F64 ) { GenerateHomographyLinear mf = new GenerateHomographyLinear ( true ) ; manager = ( ModelManager ) new ModelManagerHomography2D_F64 ( ) ; fitter = ( ModelGenerator ) mf ; if ( refineEstimate ) modelRefiner = ( ModelFitter ) mf ; distance = ( DistanceFromModel ) new DistanceHomographySq ( ) ; } else if ( motionModel instanceof Affine2D_F64 ) { manager = ( ModelManager ) new ModelManagerAffine2D_F64 ( ) ; GenerateAffine2D mf = new GenerateAffine2D ( ) ; fitter = ( ModelGenerator ) mf ; if ( refineEstimate ) modelRefiner = ( ModelFitter ) mf ; distance = ( DistanceFromModel ) new DistanceAffine2DSq ( ) ; } else if ( motionModel instanceof Se2_F64 ) { manager = ( ModelManager ) new ModelManagerSe2_F64 ( ) ; MotionTransformPoint < Se2_F64 , Point2D_F64 > alg = new MotionSe2PointSVD_F64 ( ) ; GenerateSe2_AssociatedPair mf = new GenerateSe2_AssociatedPair ( alg ) ; fitter = ( ModelGenerator ) mf ; distance = ( DistanceFromModel ) new DistanceSe2Sq ( ) ; // no refine, already optimal } else { throw new RuntimeException ( "Unknown model type: " + motionModel . getClass ( ) . getSimpleName ( ) ) ; } ModelMatcher < IT , AssociatedPair > modelMatcher = new Ransac ( 123123 , manager , fitter , distance , ransacIterations , inlierThreshold ) ; ImageMotionPointTrackerKey < I , IT > lowlevel = new ImageMotionPointTrackerKey <> ( tracker , modelMatcher , modelRefiner , motionModel , outlierPrune ) ; ImageMotionPtkSmartRespawn < I , IT > smartRespawn = new ImageMotionPtkSmartRespawn <> ( lowlevel , absoluteMinimumTracks , respawnTrackFraction , respawnCoverageFraction ) ; return new WrapImageMotionPtkSmartRespawn <> ( smartRespawn ) ; }
Estimates the 2D motion of an image using different models .