我正在使用 Qt 和 opencv 进行视频处理项目。作为处理步骤,我需要从人类经过的视频(实时流)中提取背景。我需要知道 Opencv 是否具有从视频中提取静态对象的内置函数 ?
最佳答案
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
该类实现了以下描述的高斯混合模型背景减法:
Z.Zivkovic,改进的背景自适应高斯混合模型 减法,国际 session 模式识别,英国, 2004 年 8 月, http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf .代码是 非常快并且还执行阴影检测。高斯数 组件按像素调整。
关于c++ - 从视频中提取背景场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14607674/