colormap-collect-average!

Synopsis

(colormap-collect-average! average-colormap frame weight)

Parameters

  • average-colormap
  • frame
  • weight

Description

This procedure collects a weighted running average in average-colormap. The dimensions of the two colormaps need to be identical.

Side Effects

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);

Return Value

The modified average-colormap is returned.

Example

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)