Code

简单背景差分

In this approach, we assume that the background is static. If some parts of our background start moving, then those parts will start getting detected as new objects. So, even if the movements are minor, say a waving flag, it will cause problems in our detection algorithm. This approach is also sensitive to changes in illumination, and it cannot handle any camera movement. Needless to say, it’s a delicate approach! We need something that can handle all these things in the real world.

混合高斯法

OpenCV By Example上的MOG没法使用，查了查cv::bgsegm::BackgroundSubtractorMOG也无法使用…查看文档好像又是cv::cuda::BackgroundSubtractorMOG，仍然没办法使用，可能是编译的时候没有添加支持的问题。于是就看了看官方给的demo，用的MOG2.

cmake .
make
./Clions -vid /home/shensir/Documents/MyPrograming/Cpp/Clions/data/BGC.avi

Index: 5
Prefix: /data/
Index2: 7
suffix: .jpg
nextFrameFilename: /data/2.jpg

250
640
1024
1500
666

Refrence

OpenCV By Example