My issue: I am trying to display an external (USB) webcam using OpenCV. However, it breaks a lot. The internal webcam works great with my code and is not laggy at all. However, the webcam is super laggy.
Here is my code:
import cv2
cv2.namedWindow("Camera")
vc = cv2.VideoCapture(1) #VideoCapture(0) uses the internal webcam, VideoCapture(1) uses external webcam
if vc.isOpened(): # try to get the first frame
rval, frame = vc.read()
#rval2, frame2 = vc2.read()
else:
rval = False
#rval2 = False
while rval:
frame = cv2.resize(frame, (400,480))
cv2.imshow("Camera", frame)
rval, frame = vc.read()
key = cv2.waitKey(20)
if key == 27: # exit on hitting ESC
break
cv2.destroyWindow("Camera")
vc.release()
"Is the webcam itself laggy?" No: I tried to run the external webcam in OBS to see if it would work, and it performed very well. There was no lag whatsoever.
What could be the problem? Does opencv just not perform well with usb cameras? Is there a fix?
Thank you.