【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!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM