简体   繁体   中英

Extract background scene from video

I am working on a video processing project using Qt and opencv. As a processing step I need to extract the background from a video (real time streaming) in which humans pass by. I need to know whether Opencv has inbuilt functions for extracting static objects from a video ?

Have a look at this OpenCV class .

cv::Mat original;     // your frame
cv::Mat foreground;   // your foreground
cv::Mat background;   // your background

cv::BackgroundSubtractorMOG2 mog;

mog.history = 150;            // How many frames should be used for calculation
mog.nShadowDetection = false; // There are a lot of parameters to adjust

mog(original,foreground,0.01);  // Binary foreground saved in "foreground"

mog.getBackgroundImage(background); // Output the current background of the model

The class implements the Gaussian mixture model background subtraction described in:

Z.Zivkovic, Improved adaptive Gausian mixture model for background subtraction, International Conference Pattern Recognition, UK, August, 2004, http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf . The code is very fast and performs also shadow detection. Number of Gausssian components is adapted per pixel.

The fastest method and the easy one is to use the median of the previous frames

you can use an update process of the first background image to take into account the new static objects more sophisticated method like Pinciple Component Analysis- Mixture of Gaussians- Self-organizing Background subtraction and CNN can resolve your problem but are not suitable for streaming unless you are using special hardware FPGA or GPU

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM