Ask Your Question

Revision history [back]

you can use cv::addWeighted to sum up the images. Assume that you have an empty image in which you want to store the images (dst) and read the video frames into a matrix src. your code could then look like:

cnt = 0; dst = EmptyImageSameSizeAsVideoSource while true: src = loadNewFrame() cv::addWeighted(dst,1,src,0.2,dst) # dst += 0.2*src cnt = cnt +1; if cnt%5 == 0: DoSomeMagic(dst) # dst is your mean image! dst.setTo(0)

you can use cv::addWeighted to sum up the images. Assume that you have an empty image in which you want to store the images (dst) and read the video frames into a matrix src. your code could then look like:like (just pseudo-Code):

 cnt = 0;
 dst = EmptyImageSameSizeAsVideoSource
EmptyImageSameSizeAsVideoSource()
while true:
src = loadNewFrame()
loadNewFrameFromStream()
 cv::addWeighted(dst,1,src,0.2,dst) # dst += 0.2*src
cnt = cnt +1;
if cnt%5 == 0:
DoSomeMagic(dst) # dst is your mean image!
dst.setTo(0)

dst.setTo(0)