Changing variable does not affect results

Viewed 52

I am trying to create a background subtractor with the algorithm backgroundSubtractorKNN and I have a problem with the function apply. This function has an attribute called learningRate, but if I change the value of this rate nothing happens in my results. Does anybody know what is happening?

Here is my code:

import cv2 as cv    
import numpy as np

learningRate=0.05
fgbg= cv.createBackgroundSubtractorKNN() 
cap=cv.VideoCapture('some_video.mp4')

if not cap.isOpened():
    print('Unable to open: ')
    exit(0)

while True:
    ret,frame=cap.read()
    if frame is None:
        print("me voy")
        break
    frame=cv.resize(frame,(320,240)) 
    fgmask=fgbg.apply(frame,learningRate)
    
    cv.imshow('Frame',frame)
    cv.imshow('FG MASK Frame',eroded2)

    keyboard=cv.waitKey(30)

    if keyboard=='q' or keyboard ==27:
        break

cap.release()
cv.destroyAllWindows()
0 Answers
Related