matlab - reading and displaying video file frame by frame -
I am recently working with Matlab I want to read a video file and calculate something in every frame And display every frame. I wrote the following code, but every time it shows only the first frame, nobody can help.
mov = VideoReader ('c: \ vid \ Akiyo.mp4'); NFrames = mov.NumberOfFrames; I = 1 for: nFrames videoFrame = reading (mov, i); Imshow (videoFrame); << Code>
Note: mmreader has been API Closed by MATLAB, it likes to use the VideoReader . View comment by @Vivek.
I usually do this:
obj = mmreader ('c: \ vid \ Akiyo .mp4'); NFrames = obj.NumberOfFrames; K = 1: nFrames for img = read (obj, k); Figure (1), imshow (img, []); End As far as your code is concerned, I saw the documentation of MATLAB. You should work in the following order:
mov = VideoReader ('c: \ vid \ Akiyo.mp4'); Read vidFrames = (MOV); NFrames = mov.NumberOfFrames; I = 1 for: nFrames imshow (vidFrames (:,:, i), []); % Frames are grayscale end
Comments
Post a Comment