My built in camera for my Windows computer doesn’t work. So I bought an Emeet webcam that is plugged in to the usb port of my computer. The webcam itself works in the camera app and on zoom, however, when I try to display it in OpenCV, it just gives me a black screen, which is the same as my built in camera since that doesn’t work. Here is my code:
import numpy as np import cv2 video_capture_0 = cv2.VideoCapture(0, cv2.CAP_DSHOW) #the line below is for my usb webcam video_capture_1 = cv2.VideoCapture(2, cv2.CAP_DSHOW) while True: # Capture frame-by-frame ret0, frame0 = video_capture_0.read() ret1, frame1 = video_capture_1.read() if (ret0): # Display the resulting frame cv2.imshow('Cam 0', frame0) if (ret1): # Display the resulting frame cv2.imshow('Cam 1', frame1) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything is done, release the capture video_capture_0.release() video_capture_1.release() cv2.destroyAllWindows()
Both windows open up (one for my built in camera and the other for my usb webcam) but both show black screens. For my built in camera, that is expected since it doesn’t work, but I would expect my usb webcam to actually show an image. Any suggestions on why the usb webcam doesn’t work in opencv?