public boolean update ( Image input , RectangleRotate_F64 output ) { if ( trackLost ) return false ; trackFeatures ( input , region ) ; // See if there are enough points remaining. use of config.numberOfSamples is some what arbitrary if ( pairs . size ( ) < config . numberOfSamples ) { System . out . println ( "Lack of sample pairs" ) ; trackLost = true ; return false ; } // find the motion using tracked features if ( ! estimateMotion . process ( pairs . toList ( ) ) ) { System . out . println ( "estimate motion failed" ) ; trackLost = true ; return false ; } if ( estimateMotion . getFitQuality ( ) > config . robustMaxError ) { System . out . println ( "exceeded Max estimation error" ) ; trackLost = true ; return false ; } // update the target's location using the found motion ScaleTranslateRotate2D model = estimateMotion . getModelParameters ( ) ; region . width *= model . scale ; region . height *= model . scale ; double c = Math . cos ( model . theta ) ; double s = Math . sin ( model . theta ) ; double x = region . cx ; double y = region . cy ; region . cx = ( x * c - y * s ) * model . scale + model . transX ; region . cy = ( x * s + y * c ) * model . scale + model . transY ; region . theta += model . theta ; output . set ( region ) ; // make the current image into the previous image swapImages ( ) ; return true ; }
Given the input image compute the new location of the target region and store the results in output .