My apologized. Used same as above. Change value cv2.bilateralFilter(5, 5, 3). Change this to waitKey(0). The output is not streaming. It is still images. You may have to play around values. I got fingers counting up to 5. Don’t forget set lighting. Or change skin colour code. Actually, there is something wrong with your code. I will try pi 3B+. later.
As for now, I will not be using cv2.createBackgroundSubtractorMOG2. for now.