Skip to content

Simple and superfast implementation of background subtraction

License

Notifications You must be signed in to change notification settings

sickmz/background-subtraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

background-subtraction

Background subtraction is a major preprocessing steps in many vision based applications. For example, consider the cases like visitor counter where a static camera takes the number of visitors entering or leaving the room, or a traffic camera extracting information about the vehicles etc. In all these cases, first you need to extract the person or vehicles alone. Technically, you need to extract the moving foreground from static background

Basic methods

The basic methods have several limitations:

  • They are based on the history of the single pixel;
  • They don't use spatial information;
  • The thresholds and parameters are difficult to to choose.

The methods applied in this simple example are:

  • Previous frame: the background estimated at step 'n' is the image analyzed in step 'n-1';
    equation
  • Moving average: the background is estimated as the average of the last 'k' frames ('k' determines how much quickly the background adapts to changes);
    equation
  • Exponential moving average: the alpha parameter determines the speed of background update.
    equation

Prerequisites

sudo apt-get install libopencv-dev python3-opencv
bash install-opencv.sh

Results

Previous frame:

Moving average:

Exponential moving average:

About

Simple and superfast implementation of background subtraction

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published