Home > polypedal > crosstrack > tkTrackbackpack_trackcross.m

tkTrackbackpack_trackcross

PURPOSE ^

state variables are (ukfx):

SYNOPSIS ^

function ts = tkTrackbackpack_trackcross( ts )

DESCRIPTION ^

 state variables are (ukfx):
 1-3 rig rot angles xyz, 4-6 position xyz, vel xy, acc xy

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ts = tkTrackbackpack_trackcross( ts )
0002 
0003 % state variables are (ukfx):
0004 % 1-3 rig rot angles xyz, 4-6 position xyz, vel xy, acc xy
0005 if isfield( ts, 'ukfxyz0' )
0006     ts.ukf0 = newUkfCamConstAnoZ( ts.camspec.dlt, ts.backpack.mdl, ts.ukfxyz0, 1 );
0007 else
0008     ts.ukf0 = newUkfCamConstAnoZ( ts.camspec.dlt, ts.backpack.mdl, [0;0;0;0;0;0;0;0;0;0], 1 );
0009 end
0010 ts.ukf0.Rm = ts.ukf0.R * (200);
0011 
0012 if ~isfield( ts, 'starttrackingframe' )
0013     % old style code--don't have a starting frame to track from--use 1
0014     topms = newMarkerSpecFromTrack([],ts.toptrack);
0015     topms.p0 = topms.plan(:,1);
0016     [ts.q ts.x] = runCrossUkfTracker( ts.src, ts.ukf0, {ts.mbxc{1:4} topms} );
0017 else
0018     % split tracking into forward and backward around starttrackingframe
0019     % note that it can be first or last frame:
0020     forwardframes = ts.trackedframeinds( find( ts.trackedframeinds >= ts.starttrackingframe ))';
0021     backwardframes = ts.trackedframeinds( find( ts.trackedframeinds <= ts.starttrackingframe ))';
0022     if (length( backwardframes ) > 1)
0023         % need to track backward:
0024         bsrc = ts.src;
0025         bsrc{end+1} = newFrameSourceResampler( bsrc, backwardframes(end:-1:1) - ts.trackedframeinds(1) + 1 );
0026         
0027         topms = newMarkerSpecFromTrack([],...
0028             ts.toptrack( backwardframes(end:-1:1) - ts.trackedframeinds(1) + 1 ) );
0029         topms.p0 = topms.plan(:,1);
0030         [backq backx] = runCrossUkfTracker( bsrc, ts.ukf0, {ts.mbxc{1:4} topms} );
0031         % now note backq,x goes from center backwards as index gets bigger...
0032     else
0033         backq = [];
0034     end
0035     if (length( forwardframes ) > 1)
0036         % need to track forward:
0037         fsrc = ts.src;
0038         fsrc{end+1} = newFrameSourceResampler( fsrc, forwardframes - ts.trackedframeinds(1) + 1 );
0039 
0040         topms = newMarkerSpecFromTrack([],...
0041             ts.toptrack( forwardframes - ts.trackedframeinds(1) + 1 ) );
0042         topms.p0 = topms.plan(:,1);
0043         [forq forx] = runCrossUkfTracker( fsrc, ts.ukf0, {ts.mbxc{1:4} topms} );
0044     else
0045         forq = [];
0046     end
0047     if( isempty( backq ) )
0048         ts.x = forx;
0049         ts.q = forq;
0050         return;
0051     end
0052     if( isempty( forq ) )
0053         ts.q = backq(end:-1:1,:);
0054         ts.x = backx(:,end:-1:1);
0055         return;
0056     end
0057     % Now stitch together--1 frame overlap:
0058     % have fallen through, must have done some frames each way:
0059     ts.q = [backq((end-1):-1:1,:); forq];
0060     ts.x = [backx(:,(end-1):-1:1) forx];
0061 end

Generated on Mon 02-Aug-2010 16:44:38 by m2html © 2003