Get width and height of a video frame
조회 수: 14 (최근 30일)
이전 댓글 표시
I am trying to exctract frames from an avi video and save each on an Array. The code is the following:
if true
folder = fileparts(which('Field_adv_diff_2D.avi'));
movieFullFileName= fullfile(folder,'Field_adv_diff_2D.avi');
videoObject = VideoReader(movieFullFileName);
numberOfFrames = videoObject.NumberOfFrames;
for frame = 1:numberOfFrames
thisFrame = read(videoObject,frame);
info = imfinfo(thisFrame);
w = info.Width;
h = info.Height;
processo=zeros(560,420,numberOfFrames);
processo(:,:,frame)=thisFrame;
end
end
I get this error:
Error using imfinfo (line 81) Expected FILENAME to be one of these types:
char
Instead its type was uint8.
Error in Get_Frame_Color_and_Set (line 51) info = imfinfo(thisFrame);
So, how might I get Width and Height of a video frame witch is uint8 instead of char?
Many thanks
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 11월 6일
height = size(thisFrame,1)
width = size(thisFrame, 2)
Note: in avi files, the frame size is always the same for all frames in a movie.
댓글 수: 2
Walter Roberson
2017년 11월 6일
for frame = 1:numberOfFrames
thisFrame = read(videoObject,frame);
if frame == 1
h = size(thisFrame,1);
w = size(thisFrame,2);
processo = zeros(h, w, 3, numberOfFrames);
end
processo(:, :, :, frame) = thisFrame;
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!