The OpenCV Video Surveillance Module
Unofficial Documentation
This is an attempt to document the OpenCV Video Surveillance Module.
It is at the moment, just a collection of insights from working with the under-documented code, and not a complete full documentation. In fact, at the moment this document will only focus on the Foreground / Background Segmentation part of the complete algorithm. Please feel free to add more details, improve the layout and edit the contents. (AdiShavit)
The module consists of multiple layers and modules.
An article describing the complete system can be found here:
Chen, T.; Haussecker, H.; Bovyrin, A.; Belenov, R.; Rodyushkin, K.; Kuranov, A.; Eruhimov, V. "Computer Vision Workload Analysis: Case Study of Video Surveillance Systems." Intel Technology Journal. (May 2005). (PDF)
Foreground / Background Segmentation
The implementation supports 3 algorithms:
CV_BG_MODEL_FGD
CV_BG_MODEL_FGD_SIMPLE
CV_BG_MODEL_MOG
CV_BG_MODEL_FGD[_SIMPLE]
1 and 2, are apparently related. This is an implementation of Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian.Foreground Object Detection from Videos Containing Complex Background. ACM MM2003 Paper ishere. If you know of a free link, please update this link/page.
Internally(in cvbgfg_acmmm2003.cpp) it uses another algorithm for change detection: P.Rosin, Thresholding for Change Detection, ICCV, 1998, available here (pdf).
Parameters for this module are give in the CvFGDStatModelParams struct:
typedef struct CvFGDStatModelParams
{
int Lc, N1c, N2c, Lcc, N1cc, N2cc, is_obj_without_holes, perform_morphing;
float alpha1, alpha2, alpha3, delta, T, minArea;
}
CvFGDStatModelParams;
This is initialized with the defaults:
/* default paremeters of foreground detection algorithm */ #define CV_BGFG_FGD_LC 128 #define CV_BGFG_FGD_N1C 15 #define CV_BGFG_FGD_N2C 25 #define CV_BGFG_FGD_LCC 64 #define CV_BGFG_FGD_N1CC 25 #define CV_BGFG_FGD_N2CC 40 /* BG reference image update parameter */ #define CV_BGFG_FGD_ALPHA_1 0.1f /* stat model update parameter 0.002f ~ 1K frame(~45sec), 0.005 ~ 18sec (if 25fps and absolutely static BG) */ #define CV_BGFG_FGD_ALPHA_2 0.005f /* start value for alpha parameter (to fast initiate statistic model) */ #define CV_BGFG_FGD_ALPHA_3 0.1f #define CV_BGFG_FGD_DELTA 2 #define CV_BGFG_FGD_T 0.9f #define CV_BGFG_FGD_MINAREA 15.f #define CV_BGFG_FGD_BG_UPDATE_TRESH 0.5f
If we want to update alpha2, the paper explains:
If we think that n frames for the system to response to an “once-off” background change is quick enough, we should choose the learning rate alpha2 from (22):
(22) alpha2 > 1 - (1 - T)^(1/n)
As example, if we want the system to response to an ideal "once-off" background change after 20 seconds with 25 fps frame rate and T = 90%, alpha2 should be larger than 0.0046 but not too larger than it to prevent the system not to sensitive to noise and foreground objects. So:
n = 20*25 = 500 T = 0.9 => 0.005f = CV_BGFG_FGD_ALPHA_2 = alpha2 > 1 - ((1 - 0.9)^(1 / 500)) = 0.00459458265
T is a percentage value which determines when the new features can be recognized as new background appearance. With a large value of T, the system is stable but slow to response to the "once-off" changes. However, if T is small, the system is easy to learn the frequent foreground features as new background appearances. In our tests, T was set as 90%.
CV_BG_MODEL_MOG
This is an implementation of the Mixture of Gaussians paper: P. KadewTraKuPong and R. Bowden,An improved adaptive background mixture model for real-time tracking with shadow detection, in Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001. It can be foundhere (pdf)(citeceer).
just a comment
Due to the complexity of the process and lack of documentation, the following link may be quite helpful in understanding all the necessary steps. http://www.merl.com/papers/docs/TR2003-36.pdf
