Could it be a hardware issue due to the shutter speed of the camera? Do you have the camera set to NTSC or PAL?
I can't run your code right now, but I suggest you debug your code by setting breakpoints in your code to see what is exactly happening.
Did you see this thread? -> https://stackoverflow.com/a/54444910/22773318