import cv2 as cv cap = cv.VideoCapture(0) 而 True: ret, img = cap.read() if ret: cv.imshow('img', img) if cv.waitkey(1) == ord('Q'): break
时间: 2023-05-24 16:07:33 浏览: 184
win2008 import cv2报错解决方案
#The code displays video from the webcam till 'Q' key is pressed to quit.
import cv2 as cv
cap = cv.VideoCapture(0)
while True:
ret, img = cap.read()
if ret:
cv.imshow('img', img)
if cv.waitKey(1) == ord('Q'):
break
cap.release()
cv.destroyAllWindows()
阅读全文