How do I read each frame of a video?

조회 수: 6 (최근 30일)
L'O.G.
L'O.G. 2023년 5월 3일
답변: Image Analyst 2023년 5월 4일
For an .avi file, I can read in the file using video = VideoReader(filename) and then read the first frame using readFrame(video) which gives me an array of type uint8. How do I read aeach frame?

채택된 답변

Kevin Holly
Kevin Holly 2023년 5월 3일
You can use a while loop as shown in the documentation here.
Note, you can save a 3D/4D matrix of the video if memory permits by defining a variable as such:
ii = 1;
while hasFrame(vidObj)
vidFrame(:,:,:,ii) = readFrame(vidObj); %vidFrame(:,:,:,ii) for color image and vidFrame(:,:,ii) for gray image
ii = ii+1;
end

추가 답변 (1개)

Image Analyst
Image Analyst 2023년 5월 4일

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by