0001 function [] = topMarkerSanityCheck( filespec )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if nargin < 1
0016 error('Must give a filespec, e.g. ''mov/*.avi'' or ''mov/20080806-1511-r4.avi''.');
0017 end
0018
0019
0020 files = fileList(filespec);
0021
0022
0023 if length(files) == 0
0024 disp(['Warning: no movies found for file specification ',files]);
0025 end
0026
0027 ninterpolate = 9;
0028
0029
0030 for f = 1:length(files)
0031
0032
0033 directory = files(f).directory;
0034
0035
0036 prefix = strtok(files(f).name,'.');
0037
0038
0039 if exist([directory,prefix,'-top-track.mat'],'file') || exist([directory,prefix,'-top-wp.mat'],'file')
0040
0041 disp(['Top sanity check: ',directory,prefix,'.avi . . .']);
0042
0043
0044 trajF = [];
0045 trajB = [];
0046 traj = [];
0047
0048
0049 close all;
0050 sfig = figure;
0051 axis equal;
0052 hold on;
0053
0054
0055 leg = {};
0056
0057
0058 if exist([directory,prefix,'-top-track.mat'],'file')
0059
0060 disp(['Loading ',directory,prefix,'-top-track.mat . .']);
0061
0062
0063 load([directory,prefix,'-top-track.mat'],'top');
0064
0065
0066 for w = 1:size(top.waypoints,1)-1
0067 if w <= length(top.trackF) && ~isempty(top.trackF{w})
0068 trajF(top.waypoints(w,3):top.waypoints(w+1,3)) = top.trackF{w}.traj;
0069 else
0070 trajF(top.waypoints(w,3):top.waypoints(w+1,3)) = nan;
0071 end
0072 end
0073
0074
0075 for w = size(top.waypoints,1):-1:2
0076 if w <= length(top.trackB) && ~isempty(top.trackB{w})
0077 trajB(top.waypoints(w,3):-1:top.waypoints(w-1,3)) = top.trackB{w}.traj;
0078 else
0079 trajB(top.waypoints(w,3):-1:top.waypoints(w-1,3)) = nan;
0080 end
0081 end
0082
0083 if ~isempty(trajF)
0084
0085 plot(trajF, 'b', 'LineWidth', 2);
0086 plot(trajB, 'g', 'LineWidth', 2);
0087
0088
0089 leg = {leg{:}, 'forward-time', 'backward-time'};
0090 end
0091
0092 end
0093
0094
0095
0096 if exist([directory,prefix,'-top-wp.mat'],'file')
0097
0098 disp(['Loading ',directory,prefix,'-top-wp.mat . .']);
0099
0100
0101 load([directory,prefix,'-top-wp.mat'],'top');
0102
0103 if isempty(top.waypoints)
0104 disp(['Warning: no waypoints in file.']);
0105 continue;
0106 end
0107
0108
0109 traj = [];
0110 if isfield(top,'trajectory')
0111 traj = top.trajectory;
0112 end
0113
0114 if ~isempty(traj)
0115
0116 plot(traj, 'r');
0117
0118
0119 leg = {leg{:}, 'composite'};
0120 end
0121
0122 end
0123
0124
0125
0126
0127
0128
0129
0130
0131 plot(top.waypoints(:,[1 2]) * [1; i],'ro', 'MarkerSize', 10);
0132 plot(top.waypoints(:,[1 2]) * [1; i],'r.', 'MarkerSize', 10);
0133 leg = {leg{:}, 'waypoints'};
0134
0135
0136 offset = 10;
0137 for w = 1:size(top.waypoints,1)
0138 text(top.waypoints(w,1)+offset,top.waypoints(w,2),[num2str(top.waypoints(w,3))],'VerticalAlignment','middle');
0139 end
0140
0141
0142 legend(leg);
0143
0144
0145
0146 drawnow;
0147
0148
0149 img = getframe(sfig);
0150 imwrite(img.cdata, [directory,prefix,'-top-check.png'], 'png');
0151 end
0152 end
0153
0154