## 标题MATLAB
申明:本文作者与https://shishanyue.site/blog的作者是同一人,建议到https://shishanyue.site/blog阅读(有MATLAB下载,附破解)
obj=VideoReader(‘F:/Arduino/badapple.mp4’);%读取视频路径
numOfFrames = obj.Duration * obj.frameRate;
fid=fopen(‘F:/Arduino/3.bin’,‘ab’);%创建输出文件
for u=0:numOfFrames%循环遍历每一帧
%disp(u);
frame=imresize(read(obj,u),[64,85]);%读取当前帧图像,并压缩至85x64
data_bin=frame(:,:,1)>127;%二值化图像
data_bin=data_bin(😃;%转为列向量
len=length(data_bin);%获取列向量长度
str=num2str(reshape([reshape(data_bin,64,len/64),zeros(64,3)]’,8,(64*3+len)/8)’);
res=bin2dec(str);
fwrite(fid,res,‘uchar’);
% image(frame);%用image函数绘图
% axis image off%保持宽高比,并隐藏坐标轴
% getframe;%显示画面到屏幕
end
fclose(fid);