?? spiht_hard.m
字號:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%First Step is converting Video to frames and taking 10 frames
fprintf('\n Frame Conversion Process Started........');
video = aviread('video2.avi',1:10); %get only the first 10 frames
for i = 1:10
ee = video(i).cdata;
filename = strcat(num2str(i),'.bmp');
ee = rgb2gray(ee);
ee = imresize(ee,[64 64]);
imwrite(ee,filename);
end;
fprintf('\n Frame Conversion Process ended........');
fprintf('\n Creating Serial Port Session....');
s = serial('COM1');
set(s,'BaudRate',115200,'StopBits',1,'FlowControl','none','Parity','none','DataBits',8,'outputBufferSize',5000);
s.InputBufferSize=5000;
s.TimeOut=10;
fprintf('\n Serial Port session is Created');
fopen(s);
% while(1)
% if(fread(s,1)=='N') fwrite(s,'N'); break; end;
% fwrite(s,'N');
% end;
%%For AutoBaud Detection
fwrite(s,'@');
for i = 1:10
filename = strcat(num2str(i),'.bmp');
a = imread(filename);
% a = imresize(a,[64 64]);
%%For Synchronizing the MATLAB and DSP
fwrite(s,'@');
fprintf('\n Wait While image %d is being Sent.........', i);
a1 = a(1:16,:)';
a1 = a1(:) ;
a2 = a(17:32,:)';
a2 = a2(:) ;
a3 = a(33:48,:)';
a3 = a3(:) ;
a4 = a(49:64,:)';
a4 = a4(:) ;
fwrite(s,a1);
fwrite(s,a2);
fwrite(s,a3);
fwrite(s,a4);
% if(isempty(image1)) continue;
% elseif(length(image1)==4097) break;
% end;
% end;
fprintf('\n Image %d is Sent Successfully',i);
fwrite(s,'@');
out{i} = fread(s,4097);
image2 = out{i};
if image2(1)=='#' %%%%%Ok%%%%%%%%%%%%%
fprintf('\nCompressed Image is received\n');
else
fprintf('\nCompressed Image is not received properly\n');
end;
end;
fclose(instrfind);
av = avifile('compressed4.avi');
for i = 1:10
se = out{i};
se = se(2:end);
se = reshape(se,[64 64]);
se = se';
imshow(se,[]);
% se = uint8(se);
% sd = im2frame(se);
sd = getframe(gcf);
av = addframe(av,sd);
end;
% movie('compressed.avi');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -