这个函数“createBackgroundSubtractorMOG2”的历史是什么意思?

时间:2018-01-10 09:10:28

标签: python opencv

我只在这个link中看到这个描述,它没有非常详细的解释,所以我想知道在哪里可以找到更详细的解释。官方网络文件说“长度的历史“,什么”历史的长度“是什么?

enter image description here

我的代码:

import os
import time
import cv2

def main():
    img_src_dirpath = r'C:/Users/Shinelon/Desktop/SRC/'
    dir = r'D:/deal_pics/' + time.strftime('%Y-%m-%d') + '/'
    if not os.path.exists(dir):
        os.makedirs(dir)
    img_dst_dirpath = dir
    history = 60
    varThreshold = 16
    detectShadows = True
    mog2 = cv2.createBackgroundSubtractorMOG2( history, varThreshold, detectShadows )
    for f in os.listdir( img_src_dirpath ):
        if f.endswith( '.jpg' ):
            img = cv2.imread( img_src_dirpath + f )
            mog2.apply( img )
            bg = mog2.getBackgroundImage()
            cv2.imwrite( img_dst_dirpath + f, bg )
    cv2.destroyAllWindows()

if __name__ == '__main__':
    main()

1 个答案:

答案 0 :(得分:2)

正如@ usr2564301所说,getHistory为你提供了很好的人类语言解释

  

返回影响背景模型的最后帧数。

如果您需要对其进行数学解释,我建议您阅读此算法所基于的An improved adaptive background mixture model for real-time tracking with shadow detection论文。 您可以从来源(12history中看到,learningRate用于计算RedirectMatch 301 ^/xx/?$ /xx/zzzzz ,该文件在本文中基本上是alpha

enter image description here

相关问题