how can i convert the video into frames and take snapshots of selected frames
조회 수: 4 (최근 30일)
이전 댓글 표시
i have used mmreader to read the video
댓글 수: 0
답변 (1개)
Christiaan
2015년 4월 29일
편집: Christiaan
2015년 4월 29일
Dear Sondhi,
You can use the "read" and "imshow" function to plot two frames. Instead of mmreader, VideoReader is now used. (after MATLAB R2010b). An example has been shown below how a video can be loaded into MATLAB, played and how a certain frame can be selected.
clc;clear all;close all;
xyloObj = VideoReader('xylophone.mpg', 'Tag', 'My reader object');
get(xyloObj)
xyloObj = VideoReader('xylophone.mpg');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
% Preallocate movie structure.
mov(1:nFrames) = ...
struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
'colormap', []);
% Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(xyloObj, k);
end
% Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])
% Play back the movie once at the video's frame rate.
movie(hf, mov, 1, xyloObj.FrameRate);
% plot frame 6 and 60
figure(2)
plot = read(xyloObj, 6);
imshow(plot)
figure(3)
plot = read(xyloObj, 60);
imshow(plot)
Good luck! Christiaan
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!