I am trying to use a HP webcam as a camera device for the BrainyPi.
I am using OpenCV and Python to code.
I used the following code
import cv2
camera = cv2.VideoCapture(5)
5 is got from BrainyPi documentation, generally use 0 for Windows.
while True:
ret, frame = camera.read()
cv2.imshow(‘Frame’, frame)
if cv2.waitKey(1) & 0xFF==ord('q'):
break
camera.release()
cv2.destroyAllWindows()
The indentation and working of the code is verified on Windows OS and works properly. But when executed on BrainyPi, gave the error visible in the image
The screenshot shows that the code is using /dev/video0 i.e camera device 0. Changing the code to the correct camera device number from webcamoid should fix the issue.