I tried making this code work with the raspberry pi cam. how do you make the cv2.VideoCapture(0) recognise the raspberry pi camera as the designated camera
The problem is that you are not coding safely.
If you had check the return of the method, you would know instantly that 0 is not the index of your camera:
0
import sys cam = cv2.VideoCapture(0) if not cam: print("!!! Failed VideoCapture: invalid parameter!") sys.exit()
Try numbers > 0.