0001 function movie_combine(avi_lr_file, avi_tb_file, output_file, title_str, left_is_left)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 if ~exist('title_str', 'var')
0018 title_str = 'Right View/Bottom View';
0019 end
0020 if ~exist('left_is_left', 'var')
0021 left_is_left = true;
0022 end
0023
0024
0025
0026
0027 if nargin < 2
0028 avi_dir = '\\cbi-data4\cbi-data4\rhayashi\dynamics_movie\face_naive\20151111\parm01\Sub10\movie';
0029 avi_tb_file = fullfile(avi_dir, 'bottom_view.avi');
0030 avi_lr_file = fullfile(avi_dir, 'right_view.avi');
0031 disp('Example : ');
0032 end
0033
0034
0035
0036
0037 disp(['avi file(left/right view) : ' avi_lr_file]);
0038 disp(['avi file(top/bottom view): ' avi_tb_file]);
0039 video_right = VideoReader(avi_lr_file);
0040 video_bottom = VideoReader(avi_tb_file);
0041
0042 vr_data = read(video_right);
0043 vb_data = read(video_bottom);
0044
0045
0046
0047
0048 disp('Started to play video.');
0049 close all;
0050 h = figure;
0051 set(h, 'Unit', 'pixels');
0052 set(h, 'Position', [100, 200, 1280, 768]);
0053 set(h, 'Menubar', 'none');
0054 set(h, 'Color', 'k');
0055
0056
0057
0058
0059
0060 h_axes_r = axes;
0061 h_axes_b = axes;
0062
0063
0064
0065
0066 title_font_size = 25;
0067 h_title = axes; axis off;
0068 set(h_title, 'Units', 'pixels', 'Position', [70, 680, 1, 1]);
0069 title(h_title, title_str, 'FontSize', title_font_size, 'Color', [1 1 1], 'HorizontalAlignment', 'left');
0070
0071
0072
0073
0074 if left_is_left
0075 label_strL = 'L';
0076 label_strR = 'R';
0077 else
0078 label_strL = 'R';
0079 label_strR = 'L';
0080 end
0081 label_font_size = 25;
0082
0083 h_labelL = axes; axis off;
0084 set(h_labelL, 'Units', 'pixels', 'Position', [680,380, 1, 1]);
0085 title(h_labelL, label_strL, 'FontSize', title_font_size, 'Color', [1,1,1], 'HorizontalAlignment', 'left');
0086
0087 h_labelR = axes; axis off;
0088 set(h_labelR, 'Units', 'pixels', 'Position', [1190, 380, 1, 1]);
0089 title(h_labelR, label_strR, 'FontSize', title_font_size, 'Color', [1,1,1], 'HorizontalAlignment', 'left');
0090
0091
0092
0093
0094 numFrames = get(video_bottom, 'numberOfFrames');
0095 frames(numFrames) = struct('cdata', [], 'colormap', []);
0096
0097
0098 for k=1:numFrames
0099
0100 cla(h_axes_r);
0101 image(vr_data(:, :, :, k), 'Parent', h_axes_r);
0102 set(h_axes_r, 'Unit', 'pixels');
0103 set(h_axes_r, 'Position', [-70, -20, video_right.Width, video_right.Height]);
0104 axis(h_axes_r, 'off');
0105 if nargin <= 2
0106 pause(0.03);
0107 end
0108
0109
0110 cla(h_axes_b);
0111 set(h_axes_b, 'Unit', 'pixels');
0112 image(vb_data(:, :, :, k), 'Parent', h_axes_b);
0113 set(h_axes_b, 'Position', [550, -20,video_bottom.Width, video_bottom.Height]);
0114 axis(h_axes_b, 'off');
0115 drawnow;
0116 frames(k) = getframe(h);
0117 end
0118
0119
0120
0121
0122 if exist('output_file', 'var') && ~isempty(output_file)
0123 writer = VideoWriter(output_file);
0124
0125 writer.FrameRate = video_bottom.FrameRate;
0126 writer.Quality = 100;
0127 open(writer);
0128
0129 disp('saving video...');
0130 writeVideo(writer, frames);
0131 close(writer);
0132 disp(['avi file(combined): ' output_file]);
0133 end