extract key frames from video
이전 댓글 표시
I am writing a code having following steps to extract key frames:
1) Read frames from video (let us suppose we have 700 frames)
2) Now using 'ssim' function I am finding similarity between frame 1 and successive frames. For using 'ssim' a reference frame should be there. Initially I made the first frame as reference frame. Also I took the first frame as key frame. The next frame will be keyframe if similarity is less than some threshold 'T'.
3) Suppose My 80th frame has similarity less than 'T'. Now I want to make this frame as my reference frame. And also the for loop should start from this frame only means in this case now for loop will start from 80th frame and correspondingly will find similarity between successive frames i.e.from 81st onwards.
4) I have to repeat the process till last keyframe.
Attaching here the piece of code. Kindly suugest the ways to execute the above steps.
clc;
clear all;
close all;
tic;
%reading video frames
vid=VideoReader('D:\project\Fingerspelling pics\vid6.mp4');
numFrames = vid.NumberOfFrames;
n=numFrames;
% making a folder to save the frames
Folder = 'D:\project\Fingerspelling pics\extframes\';
% writing extracted frames into the specified folder
for iFrame = 1:n
frames = read(vid, iFrame);
imwrite(frames, fullfile(Folder, sprintf('%06d.jpg', iFrame)));
end
FileList = dir(fullfile(Folder, '*.jpg'));
%here refernce is the 1st frame but I have to make such that reference should be current keyframe.
ref = imread('D:\project\Fingerspelling pics\extframes\000001.jpg');
k=0;
for iFile=1:length(FileList)
aFile = fullfile(Folder, FileList(iFile).name)
I3 = imread(aFile);
x=ssim(I3,ref);
y(k)=x;
k=k+1;
end
댓글 수: 4
Walter Roberson
2019년 12월 15일
if x < T
ref = I3;
emit I3 as a key frame
else
emit differences between I3 and ref
end
NAVNEET NAYAN
2019년 12월 15일
Walter Roberson
2019년 12월 15일
emit is obviously pseudo code here. Replace with appropriate code to accomplish what the line says.
NAVNEET NAYAN
2019년 12월 15일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Video Formats and Interfaces에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!