Key Frames Extraction in a Video
Ältere Kommentare anzeigen
Hello Everyone
I am working on a assignment "key frames extraction in a video sequence" Method that i am using as follows
->extracts frames one by one
->histogram difference between two consecutive frames using imhist() and
imabsdiff()
->calculate mean and standard deviation of difference and threshold
->continue till end of video
->again extracts frames one by one
->histogram difference between two consecutive frames using imhist() and
imabsdiff()
->compare this difference with threshold and if it is greater than threshold
select it as a key frame
->continue till end of video
is this method correct??
if anyone have good solution plz help me with the code
thanks in advance
my simple code
vid = 'Wildlife 00_00_20-00_00_30.avi';
readerobj = mmreader(vid);
for k=1: readerobj.NumberOfFrames
I=read(readerobj,k);
if(k~= readerobj.NumberOfFrames)
J=read(readerobj,k+1);
sss=absdif(I,J);
X(k)=sss;
end
end
mean=mean2(X)
std=std2(X)
threshold=std+mean*4
for k=1: readerobj.NumberOfFrames
I = read(readerobj,k);
if(k~=readerobj.NumberOfFrames)
J= read(readerobj,k+1);
sss=absdif(I,J);
if(sss>mean)
imwrite(J,strcat('D:\',Names{k+1}));
end
end
% absdif function
function [ res ] = absdif( I,J )
k=rgb2gray(I);
l=rgb2gray(J);
m=imhist(k);
n=imhist(l);
dif=imabsdiff(m,n);
res=sum(dif);
end
21 Kommentare
msp
am 1 Mär. 2013
i m getting error in following line imwrite(J,strcat('D:\',Names{k+1})); unable to write Please see whats the error.
Walter Roberson
am 1 Mär. 2013
Do you have write access to the D:\ directory?
Walter Roberson
am 1 Mär. 2013
Bearbeitet: Walter Roberson
am 1 Mär. 2013
Construct the name in one line and then use it in the next. That way you will be able to check the validity of the name construction. Also consider using fullfile() instead of strcat()
Walter Roberson
am 1 Mär. 2013
filename = fullfile('D:\', sprintf('frame_%05d.tiff', k) );
imwrite(J, filename);
msp
am 10 Mär. 2013
above code is extracting Key frame even though some duplicate or redundant frame are coming what change should make in the code.
msp
am 29 Mär. 2013
any replies
Walter Roberson
am 29 Mär. 2013
Perhaps you need to im2double() the frames.
msp
am 14 Apr. 2013
can u help me out where i should make the changes in the above code so that key frames will extracted correctly please.
msp
am 22 Apr. 2013
please any replies
msp
am 26 Apr. 2013
no reply ?
Walter Roberson
am 26 Apr. 2013
Nope.
msp
am 29 Apr. 2013
hello sir when i save frames of video they are not saved continuously they save in random order of index say example
frame_0015, frame_00124 so on... i want to save them continuously like index from 1 to n from frame_001,frame_002.... so on.
filename = fullfile('D:\', sprintf('frame_%05d.JPG', k) ); imwrite(J, filename);
help me please
Walter Roberson
am 29 Apr. 2013
Before the for loop,
frc = 0;
Then change the filename assignment to
frc = frc + 1;
filename = fullfile('D:\', sprintf('frame_%05d.JPG', frc));
msp
am 29 Apr. 2013
thank you sir.
rujul mankad
am 12 Mär. 2015
"threshold=std+mean*4 " for this how can we identify that it should be 4..and can we give global threshold?
abhishek patel
am 6 Apr. 2015
i m geting error in following line X(k)=sss.... Subscripted assignment dimension mismatch.
Ashvini babaleshwar
am 18 Jul. 2016
m getting error at last function part, can u please help me.
Walter Roberson
am 18 Jul. 2016
Please post the entire error message, everything in red. Also since there were several revisions suggested to the posted code, please post your code so we know what we are dealing with.
k swati subudhi
am 21 Okt. 2016
i am getting an error like this :Undefined function 'absdif' for input arguments of type 'uint8'. what should i do ??
Walter Roberson
am 21 Okt. 2016
Use imabsdiff instead of absdif
Shivam Thakur
am 7 Okt. 2018
Sir I work in one video project.When I try this code I get the error is " subscripted Assignment Dimension mismatch"....in line X(k)=sss.please solve the error sir.
Antworten (1)
Rajendra Oli
am 30 Mär. 2018
0 Stimmen
Is cnn algorithm used in this code?
1 Kommentar
Walter Roberson
am 30 Mär. 2018
No, cnn is not used in the above code.
It might be possible to develop a key frame extraction algorithm that uses Convolutional Neural Networks as part of the algorithm, but this is not such an algorithm.
http://ieeexplore.ieee.org/document/8311477/ CNN based key frame extraction for face in video recognition
https://www.slideshare.net/SuhasPillai1/key-frame-extraction-for-salient-activity-recognition Key Frame Extraction for Salient Activity Recognition
https://link.springer.com/chapter/10.1007%2F978-981-10-7305-2_51 Deep Key Frame Extraction for Sport Training
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!