matlab打开视频文件怎么打开方式,【Matlab系列】之视频文件读取和显示的方法

DATE: 2019-3-3

来源Tag:外包项目

1、参考

https://ww2.mathworks.cn/help/matlab/reading-and-writing-files.html

https://blog.csdn.net/liaoqix/article/details/49927735

2、Matlab中读取和显示视频文件

方法一:

VidObj = VideoReader('xylophone.mp4'); %相应修改为需要读取的视频文件

nFrames = VidObj.NumberOfFrames; %获取视频总帧数

vidHeight = VidObj.Height; %获取视频高度

vidWidth = VidObj.Width; %获取视频宽度

for k = 1 : nFrames %遍历每一帧

I = read(VidObj, k); %读出当前帧

imshow(I); %显示当前帧

pause(0.005); %暂停系统,使人眼连贯观察到每一帧,此设为0.005秒

end

方法二:

Matlab DEMO :

% Construct a multimedia reader object associated with file 'xylophone.mp4'.

vidObj = VideoReader('xylophone.mp4');

% Specify that reading should start at 0.5 seconds from the

% beginning.

vidObj.CurrentTime = 0.5;

% Create an axes

currAxes = axes;

% Read video frames until available

while hasFrame(vidObj)

vidFrame = readFrame(vidObj);

image(vidFrame, 'Parent', currAxes);

currAxes.Visible = 'off';

pause(1/vidObj.FrameRate);

end

THE END!

你可能感兴趣的:(matlab打开视频文件怎么打开方式,【Matlab系列】之视频文件读取和显示的方法)