Home

Awesome

<p align="center"> <img src="https://github.com/andrewssobral/bgslibrary/blob/master/docs/images/bgslibrary-logo.jpg?raw=true" alt="BGSLibrary" width="200"> </p>

BGSLibrary: A Background Subtraction Library

Release License: GPL v3 Platform: Windows, Linux, OS X OpenCV Wrapper: Python, MATLAB Algorithms <a href="https://app.commanddash.io/agent?github=https://github.com/andrewssobral/bgslibrary"><img src="https://img.shields.io/badge/AI-Code%20Gen-EB9FDA"></a>

<p align="center"> <a href="https://youtu.be/_UbERwuQ0OU" target="_blank"> <img src="https://raw.githubusercontent.com/andrewssobral/bgslibrary/master/docs/images/bgs_giphy2.gif" border="0" /> </a> </p>

Introduction

The BGSLibrary (Background Subtraction Library) is a comprehensive C++ framework designed for background subtraction in computer vision applications, particularly for detecting moving objects in video streams. It provides an easy-to-use and extensible platform for researchers and developers to experiment with and implement various background subtraction techniques.

Library Version

3.3.0 (see Build Status and Release Notes for more info)

Background and Development

The BGSLibrary was developed in early 2012 by Andrews Cordolino Sobral as a C++ framework with wrappers available for Python, Java, and MATLAB. It aims to facilitate foreground-background separation in videos using the OpenCV library.

Compatibility

The library is compatible with OpenCV versions 2.4.x, 3.x, and 4.x. It can be compiled and used on Windows, Linux, and Mac OS X systems.

Licensing

The library's source code is available under the MIT license, making it free for both academic and commercial use.

Getting started

<a href="https://app.commanddash.io/agent?github=https://github.com/andrewssobral/bgslibrary"><img src="https://img.shields.io/badge/AI-Code%20Gen-EB9FDA"></a>

#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>

// Include the OpenCV and BGSLibrary libraries
#include <opencv2/opencv.hpp>
#include <bgslibrary/algorithms/algorithms.h>

int main( int argc, char** argv )
{
    // Gets the names of the background subtraction algorithms registered in the BGSLibrary factory
    auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName();

    // Displays the number of available background subtraction algorithms in the BGSLibrary
    std::cout << "Number of available algorithms: " << algorithmsName.size() << std::endl;

    // Displays the list of available background subtraction algorithms in the BGSLibrary
    std::cout << "List of available algorithms:" << std::endl;
    std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator<std::string>(std::cout, "\n"));

    // Returns 0 to indicate that the execution was successful
    return 0;
}

Installation instructions

You can either install BGSLibrary via pre-built binary package or build it from source

Supported Compilers:

Other compilers might work, but are not officially supported. The bgslibrary requires some features from the ISO C++ 2014 standard.

Graphical User Interface

Wrappers

Usage examples

More

Algorithm compatibility across OpenCV versions

AlgorithmOpenCV < 3.0 (42)3.0 <= OpenCV <= 3.4.7 (41)3.4.7 < OpenCV < 4.0 (39)OpenCV >= 4.0 (26)
AdaptiveBackgroundLearning:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
AdaptiveSelectiveBackgroundLearning:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
CodeBook:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
DPAdaptiveMedian:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPEigenbackground:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPGrimsonGMM:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPMean:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPPratiMediod:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPTexture:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPWrenGA:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
DPZivkovicAGMM:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
FrameDifference:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
FuzzyChoquetIntegral:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
FuzzySugenoIntegral:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
GMG:heavy_check_mark::x::x::x:
IndependentMultimodal:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
KDE:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
KNN:x::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LBAdaptiveSOM:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LBFuzzyAdaptiveSOM:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LBFuzzyGaussian:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LBMixtureOfGaussians:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LBP_MRF:heavy_check_mark::heavy_check_mark::x::x:
LBSimpleGaussian:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
LOBSTER:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
MixtureOfGaussianV1:heavy_check_mark::x::x::x:
MixtureOfGaussianV2:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
MultiCue:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
MultiLayer:heavy_check_mark::heavy_check_mark::x::x:
PAWCS:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
PixelBasedAdaptiveSegmenter:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
SigmaDelta:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
StaticFrameDifference:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
SuBSENSE:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
T2FGMM_UM:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
T2FGMM_UV:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
T2FMRF_UM:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
T2FMRF_UV:heavy_check_mark::heavy_check_mark::heavy_check_mark::x:
TwoPoints:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
ViBe:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
VuMeter:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
WeightedMovingMean:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
WeightedMovingVariance:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:

Stargazers over time

Stargazers over time

Citation

If you use this library for your publications, please cite it as:

@inproceedings{bgslibrary,
author    = {Sobral, Andrews},
title     = {{BGSLibrary}: An OpenCV C++ Background Subtraction Library},
booktitle = {IX Workshop de Visão Computacional (WVC'2013)},
address   = {Rio de Janeiro, Brazil},
year      = {2013},
month     = {Jun},
url       = {https://github.com/andrewssobral/bgslibrary}
}

A chapter about the BGSLibrary has been published in the handbook on Background Modeling and Foreground Detection for Video Surveillance.

@incollection{bgslibrarychapter,
author    = {Sobral, Andrews and Bouwmans, Thierry},
title     = {BGS Library: A Library Framework for Algorithm’s Evaluation in Foreground/Background Segmentation},
booktitle = {Background Modeling and Foreground Detection for Video Surveillance},
publisher = {CRC Press, Taylor and Francis Group.}
year      = {2014},
}

References

Some algorithms of the BGSLibrary were used successfully in the following papers:

Videos

<p align="center"> <a href="https://www.youtube.com/watch?v=_UbERwuQ0OU" target="_blank"> <img src="https://raw.githubusercontent.com/andrewssobral/bgslibrary/master/docs/images/bgslibrary_qt_gui_video.png" width="600" border="0" /> </a> </p> <p align="center"> <a href="https://www.youtube.com/watch?v=Ccqa9KBO9_U" target="_blank"> <img src="https://raw.githubusercontent.com/andrewssobral/bgslibrary/master/docs/images/bgslibrary_youtube.png" width="600" border="0" /> </a> </p>