(colormap-collect-average! average-colormap frame weight)
This procedure collects a weighted running average in average-colormap. The dimensions of the two colormaps need to be identical.
The average-colormap is modified by computing an average value for each channel using this simple formula:
a->colormap->data[i] =
(((int) a->colormap->data[i])*weight + ((int) b->colormap->data[i]))/(weight+1);
The modified average-colormap is returned.
This example grabs a frame, collects the average over 20+1 frames and continuously displays the result (Linux only):
(define (loop)
(define frame (grabber-grab cam1))
(colormap-collect-average! avgstore frame 20)
(framebuffer-setcursor! fb 0 0)
(framebuffer-display! fb
(colormap-scale-absolute avgstore
(framebuffer-width fb) 0))
(loop))
(define fb (framebuffer-create))
(define cam1 (grabber-create "/dev/video0"))
(define avgstore (grabber-grab cam1))
(loop)