解决了这个问题之后又出现了新的问题,我们在做和视频前背景分离有关的项目,程序里本来用到的OpenCV2.2中的CvGaussBGModel在高版本已经废弃不用了,虽然网上提到混合高斯模型提取背景铺天盖地的都是CvGaussBGModel,转而使用的是cv::BackgroundSubtractorMOG和cv::BackgroundSubtractorMOG2方法,MOG是Mixture of Gaussian的缩写,所以两者实际在做一个事情,据说cv::BackgroundSubtractorMOG2是将混合高斯模型的应用发挥到极致的一个实现,下面我们就来看看两者间的差异。
在openCV2.2中,CvGaussBGModel是在\opencv2\video\background_segm.hpp中定义的,到2.4时,CvGaussBGModel已经不再使用,并移到了legacy中,也就是虽然使用原来的CvGaussBGModel即使能编译通过,也无法正常运行,而2.4中的background_segm.hpp只定义了前背景分离较新的的几种方法。
其中,BackgroundSubtractor是前背景分离的基类,BackgroundSubtractorMOG,和BackgroundSubtractorMOG2都派生自BackgroundSubtractor类,在新版本2.4.4的background_segm.hpp中这样描述这两种方法对应的文献:
/*!
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm
The class implements the following algorithm:
"An improved adaptive background mixture model for real-time tracking with shadow detection"
P. KadewTraKuPong and R. Bowden,
Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001."
http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
*/
class CV_EXPORTS_W BackgroundSubtractorMOG : public BackgroundSubtractor
{
};
/*!
The class implements the following algorithm:
"Improved adaptive Gausian mixture model for background subtraction"
Z.Zivkovic
International Conference Pattern Recognition, UK, August, 2004.
http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf
*/
class CV_EXPORTS BackgroundSubtractorMOG2 : public BackgroundSubtractor
{
public:
//! the default