How can i extract the first frame of a video and save it as an image?
14 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Geoff Hayes
2016 年 9 月 26 日
編集済み: Geoff Hayes
2016 年 9 月 27 日
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 件のコメント
Geoff Hayes
2016 年 9 月 27 日
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?
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!