Issue
I'm working on a openCV+pygame project on raspberry pi. I tested the project on Mac and it worked fine. However, when it comes to Raspberry Pi, it shows "TypeError: a bytes-like object is required, not 'NoneType'".
I figured out this error is from:
buffer = get_image()
# error is from next line
buffer = Image.frombytes('RGB', (cam_h_rez, cam_v_rez), buffer_1)
pixels = buffer.load()
where get_image() function is the following:
camera = cv2.VideoCapture(0)
#capture image
def get_image():
retval, im = camera.read()
return im
Can someone help me?
Solution
Found the solution. It turns out raspberry pi does not automatically give openCV camera permission. Use:
sudo modprobe bcm2835-v4l2
solved the problem.
Reference: https://stackoverflow.com/a/37530016/4491353
Answered By - turf Answer Checked By - Cary Denson (WPSolving Admin)