@@ -226,20 +226,20 @@ def v_concat(img1, img2):
226226 frame , (0 , 0 ), fx = args .rescale , fy = args .rescale )
227227
228228 # add current frame to background model and retrieve current foreground
229- # objects
229+ # objects (use learningRate parameter for tuning, see manual )
230230
231231 fgmask = mog .apply (frame )
232232
233- # threshold this and clean it up using dilation with a elliptical mask
233+ # threshold this and clean it up using erosion/ dilation with a elliptical mask
234234
235235 fgthres = cv2 .threshold (fgmask .copy (), 200 , 255 , cv2 .THRESH_BINARY )[1 ]
236- fgdilated = cv2 .dilate (
236+ fgeroded = cv2 .erode (
237237 fgthres , kernel = cv2 .getStructuringElement (
238238 cv2 .MORPH_ELLIPSE , (3 , 3 )), iterations = 3 )
239- fgderoded = cv2 .erode (
240- fgdilated , kernel = cv2 .getStructuringElement (
239+ fgdilated = cv2 .dilate (
240+ fgeroded , kernel = cv2 .getStructuringElement (
241241 cv2 .MORPH_ELLIPSE , (3 , 3 )), iterations = 3 )
242-
242+
243243 # get current background image (representative of current GMM model)
244244
245245 bgmodel = mog .getBackgroundImage ()
@@ -252,7 +252,7 @@ def v_concat(img1, img2):
252252 cv2 .namedWindow (window_name , cv2 .WINDOW_NORMAL )
253253 cv2 .imshow (window_name , v_concat (
254254 h_concat (frame , bgmodel ),
255- h_concat (fgmask , fgderoded )
255+ h_concat (fgmask , fgeroded )
256256 ))
257257 cv2 .setWindowProperty (window_name , cv2 .WND_PROP_FULLSCREEN ,
258258 cv2 .WINDOW_FULLSCREEN & args .fullscreen )
@@ -280,8 +280,8 @@ def v_concat(img1, img2):
280280 # It can also be set to detect specific key strokes by recording which
281281 # key is pressed
282282
283- # e.g. if user presses "x" then exit or reset MoG modelw when space is
284- # presses
283+ # e.g. if user presses "x" then exit, "f" for fullscreen
284+ # or reset MoG model when space is pressed
285285
286286 if (key == ord ('x' )):
287287 keep_processing = False
0 commit comments