【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