You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BackgroundSubtractorGSOC() does not stop updating the background model regardless of the zero learningRate factor when calling the BackgroundSubtractorGSOC.apply(<image>, None, learningRate=0).
It works fine when using the BackgroundSubtractorMOG and BackgroundSubtractorMGM, but BackgroundSubtractorGSOC and BackgroundSubtractorLSBP does not respect the learning rate. The background model keeps updating regardless of the learningRate value.
The same issue exists with BackgroundSubtractorKNN from the standard OpenCV.
Steps to reproduce
importcv2# back_sub = cv2.createBackgroundSubtractorKNN() # Has the same problem# back_sub = cv2.bgsegm.createBackgroundSubtractorLSBP() # Has the same problemback_sub=cv2.bgsegm.createBackgroundSubtractorGSOC()
cap=cv2.VideoCapture(0)
ifnotcap.isOpened():
raise (Exception("Could not open capture"))
learning_rate=0.1whileTrue:
ret, frame=cap.read()
ifnotret:
breakfg_mask=back_sub.apply(frame, None, learning_rate)
print(learning_rate)
cv2.imshow("frame", frame)
cv2.imshow("foreground", fg_mask)
cv2.imshow("background", back_sub.getBackgroundImage())
k=cv2.waitKey(1)
ifk==ord("q"):
break# Press "d" to switch learning_rate between 0.1 and 0.0elifk==ord("d"):
ifnotlearning_rate:
learning_rate=0.1else:
learning_rate=0.0cap.release()
cv2.destroyAllWindows()
Issue submission checklist
I report the issue, it's not a question
I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
I updated to the latest OpenCV version and the issue is still there
There is reproducer code and related data files (videos, images, onnx, etc)
The text was updated successfully, but these errors were encountered:
System Information
OpenCV python version: 4.8.0.76 opencv-contrib-python
Operating System / Platform: Ubuntu 22.04
Python version: 3.10.12
Detailed description
The
BackgroundSubtractorGSOC()
does not stop updating the background model regardless of the zerolearningRate
factor when calling theBackgroundSubtractorGSOC.apply(<image>, None, learningRate=0)
.It works fine when using the
BackgroundSubtractorMOG
andBackgroundSubtractorMGM
, butBackgroundSubtractorGSOC
andBackgroundSubtractorLSBP
does not respect the learning rate. The background model keeps updating regardless of the learningRate value.The same issue exists with
BackgroundSubtractorKNN
from the standard OpenCV.Steps to reproduce
Issue submission checklist
The text was updated successfully, but these errors were encountered: