问题
I am new to OpenCV and I am trying to render video from my webcam but instead of getting a continuous live video, I get a single frame as a picture. When I tap on close button it shows me the next frame as a picture.
import cv2
vid=cv2.VideoCapture(0)
while(vid.isOpened()):
ret,frame=vid.read()
cv2.imshow('Video',frame)
if cv2.waitKey(0) & 0xFF ==ord('e'):
break
vid.release()
cv2.destroyAllWindows()
I am using Asus X507uf laptop. Maybe it is my webcam's fault.
回答1:
Try this code -
import cv2
vid=cv2.VideoCapture(0)
while(vid.isOpened()):
ret,frame=vid.read()
cv2.imshow('Video',frame)
if cv2.waitKey(1) & 0xFF ==ord('e'):
break
vid.release()
cv2.destroyAllWindows()
来源:https://stackoverflow.com/questions/62638030/not-getting-a-continuous-video-output-from-webcam-in-opencv