Borrar filtros
Borrar filtros

How can i extract the first frame of a video and save it as an image?

14 visualizaciones (últimos 30 días)
abbxucy11
abbxucy11 el 26 de Sept. de 2016
Comentada: Geoff Hayes el 27 de Sept. de 2016
i use this code but it doesnt work. it has the error below, but im sure that the video is in the correct path.
THE CODE:
video =[handles.FilePath handles.FileName];
axes(handles.axesRoiVideo);
img = frame2im(VideoReader(video,1));
ERRORS:
Error using VideoReader/init (line 607)
The filename specified was not found in the MATLAB path.
Error in VideoReader (line 172)
obj.init(fileName);

Respuestas (1)

Geoff Hayes
Geoff Hayes el 26 de Sept. de 2016
Editada: Geoff Hayes el 27 de Sept. de 2016
abbxucy11 - if we assume that handles.FilePath and handles.FileName are valid, then use fullfile to create the full path and file name for your video.
videoPathAndFileName = fullfile(handles.FilePath,handles.FileName);
fprintf('Loading video file %s...\n, videoPathAndFileName);
videoObj = VideoReader(videoPathAndFileName);
I'm not sure why you are passing in a 1 as the second input parameter to VideoReader. What does this integer mean to you?
Now use readFrame to get the first frame of the video (see read video files for more details) as
firstFrame = readFrame(videoObj);
  3 comentarios
Geoff Hayes
Geoff Hayes el 27 de Sept. de 2016
When you run the above code, what happens? Are you still observing an error and if so, what is it? Please copy and paste the results of the fprintf and verify that the path to the media is valid.
Also, what version of MATLAB are you using? And does the documentation (for your version) indicate that a 1 can be passed in to extract the first frame?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by