Background Subtraction Program
by Computer Vision Lab at University of Maryland

There may be unexpected error messages you got while running the program.  Please let me know those through e-mail at knkim at  That would be of much help to me.  Thanks. (Oct. 27, 2003)

If you don't have a live camera working on your computer, you may get several DirectShow warning messages while running the program. (Oct. 27, 2003).

Introduction and overview

This background subtraction (BGS) program processes input video data captured from a static single camera to generate foreground/background binary image outputs.  Inputs can be live video (from any camera accepted by DirectShow, i.e., IEEE1394, USB camera, etc) , video files (*.avi, *.mpg, etc), or a sequence of image files (*.bmp, *.jpg, *.gif, *.ppm) .  Our codebook BGS algorithm adopts a quantization/clustering technique  to construct a background model from long observation sequences. For each pixel, it builds a codebook consisting of one or more codewords. Samples at each pixel are clustered into the set of codewords based on a color distortion metric together with a brightness ratio. Not all pixels have the same number of codewords. The clusters represented by codewords do not necessarily correspond to single Gaussian or other parametric distribution. Even if the distribution at a pixel were a single normal, there could be several codewords for that pixel. The background is encoded on a pixel by pixel basis. Thus a pixel is represented by a codebook which consists of one or multiple codewords.  Our algorithm has the following characteristics:
  • resistant to artifacts of acquisition, digitization and compression.

  • capable of modeling a long-term background, say 5 minutes, in the compressed form of codebooks with low memory capacity.  That allows us to encode moving backgrounds, for example moving trees, or multiple changing backgrounds.

  • classifies into 4 classes: stable background, moving background, target foreground, and others

  • uses color proportion with minimum brightness to avoid its uncertainty on dark colors.

  • detects multiple layers of backgrounds permanent and non-permanent backgrounds.

  • capable of coping with local and global illumination changes in both indoor and outdoor videos.

  • allows moving foreground objects in the scene during the initial training period with a constraint.

  • post-processing makes the silhouette outputs clear and exact.

This is the main window of the program.  'Files - Train - Detect' buttons can be used for a sequence of image files. 'Live-Video-Capture-Train-Detect' buttons can be used for live video or video files.

These four sub-windows represent (1) Input Image, (2) Detection Image, (3) Binary Map, and (4) Foreground Blobs respectively.

When you click 'Setting' button, you can see this dialog window.  All parameters can be adjusted here.  If you are not sure, just use the default values given initially.


Name Email Contributions
* Kyungnam Kim  knkim at He developed the current version of the BGS program and is maintaining the source codes and the program.
Thanarat Horprasert thanarat at started the project and developed the early version.
Kyongil Yoon kiyoon at implemented the DirectShow part using video processing application wizard

* contact person

Update history


Download Files Description
DirectShow Version

 . UMD-BGS.exe
. VisDisplay.dll
. VisCore.dll

This version is what is described here at the web page.  No manual but you can refer to the manual in the research version below.  Just copy these files onto any directory and run UMD-BGS.exe.  Two DLL files are required because it uses Microsoft VisSDK library 1.2.
Research Version This version is not covered in this web page, but its algorithm used is almost identical to that of DirectShow version.  If you are ok to process image sequences (not video files or live videos), this version may also be good for you.  There is a manual you can refer to.  Sometimes, this version seems to be more robust.

Citation information

If you want to use the program for your research, please put this citation information on your publication.  Thanks.


The programs can be used as a pre-processing step in many visual surveillance projects.