How can i extract the first frame of a video and save it as an image?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (1)
Geoff Hayes
le 26 Sep 2016
Modifié(e) : Geoff Hayes
le 27 Sep 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?
firstFrame = readFrame(videoObj);
3 commentaires
Geoff Hayes
le 27 Sep 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?
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!