Home

Awesome

BGSlibrary Examples in Python

This repository contains Python scripts demonstrating the use of the pybgs library, a Python wrapper for the Background Subtraction Library (BGSlibrary). The examples illustrate how to apply different background subtraction algorithms on video data and image sequences for moving object detection.

License: MIT Platform: Windows, Linux, OS X OpenCV Algorithms

BGS Library Demo

Features

Installation

To run the examples in this repository, you will need Python 3, OpenCV, NumPy, and the pybgs library. A virtual environment is recommended for managing the dependencies.

Setting Up a Virtual Environment

You can set up a virtual environment and install the necessary dependencies by following these steps:

  1. Clone the repository and navigate into it:

    git clone https://github.com/andrewssobral/bgslibrary-examples-python
    cd bgslibrary-examples-python
    
  2. Run the virtualenv.sh script to create a virtual environment and install dependencies:

    ./virtualenv.sh
    

This script will create a new virtual environment named env, upgrade pip, and install numpy, opencv-python, and pybgs.

Usage

There are several demonstration scripts included in the repository:

To run an example, make sure your virtual environment is activated, and then execute the script like so:

python demo_framediff_video.py

Replace demo_framediff_video.py with the name of the script you wish to run.

Additional Notes

Google Colab example

Please click on the link below to access the notebook example on Google Colab:

https://colab.research.google.com/drive/1HDc0cE7PDQM9zxm5z-bK_UggzIBpK2DH

The same notebook is available under the folder notebooks.

Acknowledgements

This project utilizes the pybgs library, a Python wrapper for the BGSlibrary, to demonstrate background subtraction techniques.

License

MIT License