0001 function matchedVelocities = vis_velocity(SS)
0002 matchedVelocities = [];
0003 for se = 1: length(SS)
0004
0005 auVelocities = calc_velocity(SS(se).Rich.tracks);
0006 maVelocities = calc_velocity(SS(se).GT.tracks);
0007
0008 matched = match_au_to_ma(auVelocities, maVelocities,...
0009 SS(se).Rich.RMSEx(:,1:2));
0010 matchedVelocities = [matchedVelocities; matched];
0011 end
0012
0013
0014
0015
0016
0017
0018
0019
0020 function matchedVelocities = match_au_to_ma(auVelocities, maVelocities, matchChart)
0021 maIds = unique(matchChart(:,1));
0022 matchedVelocities = zeros(length(maIds),4);
0023 for id = 1: length(maIds)
0024 maId = maIds(id);
0025 maVelocity = maVelocities(maVelocities(:,1)==maId,2);
0026 auId = unique(matchChart(matchChart(:,1)==maId,2));
0027 auVelocity = auVelocities(auVelocities(:,1)==auId,2);
0028 matchedVelocities(id,:) = [maId auId maVelocity auVelocity];
0029 end
0030 end
0031
0032 function velocity = calc_velocity(tracks)
0033 trIds = unique(tracks(:,1));
0034 velocity = zeros(length(trIds),2);
0035 for tr = 1: length(trIds)
0036 trId = trIds(tr);
0037 track = tracks(tracks(:,1)==trId,:);
0038 frIds = unique(track(:,2));
0039 totalDist = 0;
0040 for fr= 1: length(frIds)-1
0041 frId = frIds(fr);
0042 dist = calc_dist(track(track(:,2)==frId,3:4),...
0043 track(track(:,2)==frId+1, 3:4) );
0044 totalDist = totalDist + dist;
0045 end
0046 velocity(tr,:) = [trId totalDist/length(frIds)];
0047 end
0048 end
0049
0050 function dist = calc_dist(p,q)
0051 dist = sqrt( (p(1)-q(1))^2 + (p(2)-q(2))^2);
0052 end
0053
0054 end