Ask Your Question
0

What does the history of this function “createBackgroundSubtractorMOG2” means?

asked 2018-01-11 02:21:29 -0600

MadFrog gravatar image

updated 2018-01-11 02:28:30 -0600

I only see this description in this link, it hasn't a very detailed explanation, so I'd like to know where can I find a more detailed explanation.The official web document says "Length of the history", what "Length of the history" is?

image description

My code:

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()
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-01-11 06:41:21 -0600

It simply states how many previous frames are used for building the background model. So basically if an item is standing at a fixed position for as many frames as the history size, then it will disappear in the background.

edit flag offensive delete link more

Comments

Can you provide detailed information for this parameter? I have never found more.

MadFrog gravatar imageMadFrog ( 2018-01-11 07:06:58 -0600 )edit

Do you have the source code for this method? Or, for example, this parameter is 60, so is it means to generate a 61st frame of the present video with the front 60 pictures? If it is, is there a weight in the first 60 frames? Is the weight same?

MadFrog gravatar imageMadFrog ( 2018-01-11 07:17:09 -0600 )edit

The code is in the repository, and it is some kind of weighted sum, but you would have to read the paper to know the exact formula. I do not know those out of my head :D

StevenPuttemans gravatar imageStevenPuttemans ( 2018-01-11 07:20:51 -0600 )edit
1

Anyway,thank you for your help,

MadFrog gravatar imageMadFrog ( 2018-01-11 18:12:48 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-11 02:21:29 -0600

Seen: 59 times

Last updated: Jan 11