Skip to content

Commit 4319042

Browse files
committed
review bg
1 parent d87bd14 commit 4319042

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

source/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ Several algorithms were introduced for this purpose. OpenCV has implemented thre
2424
BackgroundSubtractorMOG
2525
-----------------------------------
2626

27-
It is a Gaussian Mixture-based Background/Foreground Segmentation Algorithm. It was introduced in the paper "An improved adaptive background mixture model for real-time tracking with shadow detection" by P. KadewTraKuPong and R. Bowden in 2001. It uses a method to model each background pixel by a mixture of K Gaussian distributions (K = 3 to 5). The weights the mixture represent the time proportions that those colours stay in the scene. The probable background colours are the ones which stay longer and more static.
28-
29-
For background estimation, a minimum threhold T is used which is the minimum prior probability that the background is in the scene. Background subtraction is performed by marking a foreground pixel any pixel that is more than 2.5 standard deviations away from any of the B distributions. It estimates the gaussian mixture model by statistics update equations. When first L samples are processed, it switch to L-recent window update equations which gives priority to recent data so that tracker adapt to the recent changes in environment.
27+
It is a Gaussian Mixture-based Background/Foreground Segmentation Algorithm. It was introduced in the paper "An improved adaptive background mixture model for real-time tracking with shadow detection" by P. KadewTraKuPong and R. Bowden in 2001. It uses a method to model each background pixel by a mixture of K Gaussian distributions (K = 3 to 5). The weights of the mixture represent the time proportions that those colours stay in the scene. The probable background colours are the ones which stay longer and more static.
3028

3129
While coding, we need to create a background object using the function, **cv2.createBackgroundSubtractorMOG()**. It has some optional parameters like length of history, number of gaussian mixtures, threshold etc. It is all set to some default values. Then inside the video loop, use ``backgroundsubtractor.apply()`` method to get the foreground mask.
3230

@@ -104,7 +102,7 @@ It would be better to apply morphological opening to the result to remove the no
104102
cap = cv2.VideoCapture('vtest.avi')
105103

106104
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3))
107-
fgbg = cv2.createBackgroundSubtractorMOG2()
105+
fgbg = cv2.createBackgroundSubtractorGMG()
108106

109107
while(1):
110108
ret, frame = cap.read()

0 commit comments

Comments
 (0)