Get width and height of a video frame
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 6 Nov 2017
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 Commenti
Walter Roberson
il 6 Nov 2017
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
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!