pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
822 stars 131 forks source link

Possible divide by zero in camera #2458

Open Starbuck5 opened 12 months ago

Starbuck5 commented 12 months ago

Reported: https://stackoverflow.com/questions/77107362/float-division-by-zero-python-webcam-pygame-camera

Source: https://github.com/pygame-community/pygame-ce/blob/681f5b5e4e91f813f806c13b1183a7a1e18450d6/src_py/_camera_opencv.py#L74

It makes sense that this could return 0 if unknown, and then crash. The solution is likely to rewrite the OpenCV camera backend to use threading so it can convert the blocking OpenCV API into our non blocking API.

novialriptide commented 11 months ago

Stack Overflow page redirects to a 404.

image
Starbuck5 commented 10 months ago

Ok, stack overflow question got removed. The possibility of OpenCV returning 0 as webcam FPS and leading to a divide by zero error is still there.