public void changeKeyFrame ( ) { // drop all inactive tracks since their location is unknown in the current frame List < PointTrack > inactive = tracker . getInactiveTracks ( null ) ; for ( PointTrack l : inactive ) { tracker . dropTrack ( l ) ; } // set the keyframe for active tracks as their current location List < PointTrack > active = tracker . getActiveTracks ( null ) ; for ( PointTrack l : active ) { AssociatedPairTrack p = l . getCookie ( ) ; p . p1 . set ( l ) ; p . lastUsed = totalFramesProcessed ; } tracker . spawnTracks ( ) ; List < PointTrack > spawned = tracker . getNewTracks ( null ) ; for ( PointTrack l : spawned ) { AssociatedPairTrack p = l . getCookie ( ) ; if ( p == null ) { l . cookie = p = new AssociatedPairTrack ( ) ; // little bit of trickery here. Save the reference so that the point // in the current frame is updated for free as PointTrack is p . p2 = l ; } p . p1 . set ( l ) ; p . lastUsed = totalFramesProcessed ; } worldToKey . set ( worldToCurr ) ; keyToCurr . reset ( ) ; keyFrame = true ; }
Change the current frame into the keyframe . p1 location of existing tracks is set to their current location and new tracks are spawned . Reference frame transformations are also updated