extract key frames from video

6 Ansichten (letzte 30 Tage)
NAVNEET NAYAN
NAVNEET NAYAN am 15 Dez. 2019
Kommentiert: NAVNEET NAYAN am 15 Dez. 2019
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 Kommentare
Walter Roberson
Walter Roberson am 15 Dez. 2019
emit is obviously pseudo code here. Replace with appropriate code to accomplish what the line says.
NAVNEET NAYAN
NAVNEET NAYAN am 15 Dez. 2019
yeah..yeah got it...thanks

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by