How to extract frames from a video in MATLAB?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi, I have managed to read the video frames, but how do i extract them?
videoFReader = vision.VideoFileReader('face.avi');
videoPlayer = vision.VideoPlayer;
while ~isDone(videoFReader)
videoFrame = step(videoFReader);
step(videoPlayer, videoFrame);
end
release(videoPlayer);
release(videoFReader);
Any help would be appreciated
Thank you
댓글 수: 0
채택된 답변
Image Analyst
2014년 3월 2일
And what is the difference between a "video frame", and a "screen shot"? Please upload an image of each one so we can tell the difference. Do you mean like you want the task bar, parts of MATLAB, the figure toolbar, and any other programs that might happen to be running on your program, as well as parts of your desktop to be captured and saved?
댓글 수: 6
Image Analyst
2014년 3월 6일
Sorry but it could be a complicated project and I can't afford to spend a lot of time helping you. Your code looks weird. The min is never going to be more than the max so that "if (b>a)" statement is useless - it will always do the imshow() and never ever do the msgbox(). There's no point at all to that code.
추가 답변 (1개)
cp sahu
2015년 4월 30일
편집: cp sahu
2015년 4월 30일
%this code can run on newer versions of Matlab for older versions use %mmreader instead of VideoReader
video=VideoReader('d:\dataset\taxi.mpg');
%pass the path of the video file with extension
for k = 1 : 40
%fill in the no of frames the video contains or anything less than that, The
%no of frames in a video can be identified by reading info about the video.
%i.e. the frame rate in fps, multiply it with video length in sec.
this_frame = read(video, k);
a=sprintf('Frame #%d.jpg', k); % store the name of the frame in 'a'.
imwrite(this_frame,a,'jpg'); % store the extracted frame under the compression scheme with third parameter.
end
댓글 수: 2
Anirban Kundu
2019년 4월 22일
the imwrite function is not working. It says that "Unable to open file "Frame #1.jpg" for writing. You might not have write permission." I am using Matlab 2018a. Please provide me a solution
Image Analyst
2019년 4월 22일
What is the folder you're writing to? It's not under Program Files is it, because Windows does not allow you to write there.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!