Home > polypedal > ProjectiveReconstruction > splitVideo.m

splitVideo

PURPOSE ^

Splies a video into segments that contain good data for processing

SYNOPSIS ^

function [ segment_names ] = splitVideo( filename )

DESCRIPTION ^

 Splies a video into segments that contain good data for processing
 filename is a .avi file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ segment_names ] = splitVideo( filename )
0002 % Splies a video into segments that contain good data for processing
0003 % filename is a .avi file
0004 
0005 src_init = {newFrameSourceAVI(filename)};
0006 src_init{end+1} = newFrameSourceNoM3bug;
0007 
0008 disp('Mark the start and end of video segments');
0009 
0010 selectFrames = imagePager(src_init);
0011 
0012 if sum(selectFrames.times)<2
0013     error 'Two frames required to specify a segment!';
0014 end
0015 if mod(sum(selectFrames.times), 2)>0
0016     error 'Two frames per video segment, number of markers is not even';
0017 end
0018 
0019 marked_frames = find(selectFrames.times);
0020 segment_names = cell(length(marked_frames)/2,1);
0021 
0022 for l=1:2:length(marked_frames)
0023     segment_info.next_stage = 1;
0024     segment_info.video_name = filename;
0025     segment_info.begin_frame = marked_frames(l);
0026     segment_info.end_frame = marked_frames(l + 1);
0027     
0028     start = 1;
0029     index = find(filename=='/');
0030     
0031     if length(index)>1
0032         start = index(end)+1;
0033     end
0034     
0035     segment_info.mat_file_name = [filename(start:end-4) '_seg_' num2str(marked_frames(l)) '_' num2str(marked_frames(l+1)) '.mat'];
0036     segment_names{(l+1)/2} = segment_info.mat_file_name;
0037     
0038     % frame source parameters
0039     %segment_info.find_pts_threshold = 0.55;
0040     %segment_info.find_pts_threshold = 2e-4;
0041     segment_info.window_size = 700;
0042     segment_info.pixel_per_grid = 420;
0043     
0044     src = {newFrameSourceAVI( filename )};
0045     src{end+1} = newFrameSourceResampler(src, marked_frames(l):marked_frames(l+1));
0046     src{end+1} = newFrameSourceNoM3bug;
0047     src{end+1} = newFrameSourceFilterOp(src,inline('sqrt(1-x)'));
0048 %    src{end+1} = newFrameSourceBlrXY(src,5);
0049 
0050 %   spec = [5 3;5 3];
0051 %   w = gausswin(spec(1,1),spec(1,2));
0052 %   w = reshape(w,1,length(w))/sum(w);
0053 %   h = gausswin(spec(2,1),spec(2,2));
0054 %   h = reshape(h,length(h),1)/sum(h);
0055 %
0056 %   src{end+1} = newFrameSourceFilterOp( src, ...
0057 %     inline('conv2(conv2(x,y,''same''),z,''same'')'),w,h );
0058 
0059     src{end+1} = newFrameSourceLumaFix( src, 2, 137 );
0060     w = gausswin(80,4); 
0061     w = reshape(w,1,length(w))/sum(w);
0062     src{end+1} = newFrameSourceFilterOp( src, inline('x-conv2(conv2(x,y,''same''),z,''same'')'),w,w' );
0063     src{end+1} = newFrameSourceFilterOp( src, inline('(x-min(x(:)))/range(x(:))') );
0064     
0065 %     img = getImg(src,1);
0066 %     bg = median(img(1:137:end));
0067 %     img(1:5,:)=bg;
0068 %     img(:,1:5)=bg;
0069 %     img(end-5:end,:)=bg;
0070 %     img(:,end-5:end)=bg;
0071 %     segment_info.find_pts_threshold = prctile(img(:),99);
0072     
0073     %src{end+1} = newFrameSourceFindPts(src,[segment_info.find_pts_threshold,40,400]);
0074     %src{end+1} = newFrameSourceFindPtsAdaptive(src,[97,40,400]);
0075     src{end+1} = newFrameSourceFindPtsMinor(src,[99,3,30]);
0076     
0077     segment_info.src_ini=iniFromSrc(src);
0078     
0079     dcr = srcGetDcr(src);
0080     segment_info.N = dcr.N;
0081 
0082     fr=srcGetFr(src,1);
0083     disp('Please mask out the incorrect markers present in this frame.\nRight click on the image when done');
0084     segment_info.first_polygon_to_ignore= getInteractiveMask(fr{end-2}.imgs.img,fr{end}.imgs.args.trkPos);
0085     
0086     disp('Saving segment info to files');
0087     save(segment_info.mat_file_name,'segment_info');
0088     clear segment_info;
0089 end
0090 
0091 disp(['Created video segment ' segment_names{:}]);

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