Finding the average background frame from a video sequence

3 Ansichten (letzte 30 Tage)
Algorithms Analyst
Algorithms Analyst am 15 Mär. 2013
Beantwortet: James am 27 Okt. 2013
Hi everyone
I have a video seqence and I want to apply the running average equation on this video sequence to estimate the background frame.let say I have a sequence of frames like
source=VideoReader('myvideo.avi'); frames=source.Numberofframes; for f=1:frames thisframe=read(source,f);
end
As I know that frames is equal to total number of frames in this video and f is changing after evry iteration now how can I find the average background frame which is
backgroundframe=(frame1+frame2+frame3+....+N)./frames;as in this case total number of frames are 1020. so it becomes
backgroundframe=(frame1+frame2+frame3+....+N)./1020.
how can i apply this equation.
Thanks

Antworten (1)

James
James am 27 Okt. 2013
Hi Algorithms Analyst, this is of interest to me because I'm trying to do something similar. I use a system command to run ffmpeg (www.ffmpeg.org/) to retrieve frames from the video, then average them by summing in a loop using 'imadd.m' and dividing the final sum.
Frames = uint32(imread(strcat(Folder, File_basename, num2str(1), Frame_ext)) );
for i = 1:(length(dir([Folder,File_basename)], '*',Frame_ext));
Frames = imadd(Frames,uint32(imread(strcat(Folder,File_basename,num2str(i,'%04d'), Frame_ext))) );
end
AveFrames=uint8(imdivide(AveSAMPLEFrames,length(dir([Folder,File_basename)], '*',Frame_ext)) ));
Works pretty well for me when the object is moving and lighting stays relatively constant. Not the fastest method though. Would be interested to hear if you found any better solutions since this post.

Community Treasure Hunt

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

Start Hunting!

Translated by