OpenCV 5.0.0-pre
Open Source Computer Vision
|
Prev Tutorial: High level stitching API (Stitcher class)
Next Tutorial: Meanshift and Camshift
Original author | Domenico Daniele Bloisi |
Compatibility | OpenCV >= 3.0 |
Background modeling consists of two main steps:
In the first step, an initial model of the background is computed, while in the second step that model is updated in order to adapt to possible changes in the scene.
In this tutorial you will learn how to:
In the following you can find the source code. We will let the user choose to process either a video file or a sequence of images.
We will use cv::BackgroundSubtractorMOG2 in this sample, to generate the foreground mask.
The results as well as the input data are shown on the screen.
We discuss the main parts of the code above:
apply
method.vtest.avi
video, for the following frame:The output of the program will look as the following for MOG2 method (gray areas are detected shadows):
The output of the program will look as the following for the KNN method (gray areas are detected shadows):