实验目的:从一部电影里提取出一秒里面多帧图像的一帧;
实验实代码:
clc
clear
close all
% 创建视频读取对象,并设置参数
xyloObj = VideoReader('j.mp4');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
FrameRate = xyloObj.FrameRate; % 24帧播放的
% 创建几帧数据的空间
A=nFrames/23;
A=fix(A);
frames = 1:nFrames;
mov(1:length(frames)) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'), 'colormap', []);
% 读数据
for k = 1 : 500
i=23*k;
mov(i).cdata = read(xyloObj, frames(i));
str=strcat('D:\pictures\',int2str(k),'.jpg')