opencv打开摄像头
import cv2 as cv
cap = cv.VideoCapture(0)
while True:
ret, frame = cap.read()
cv.imshow("video", frame)
if cv.waitKey(1) == 27:
break
if cv.waitKey(1) == ord("e"):
break
cap.release()
cv.destroyAllWindows()
参考链接:
解决win10下python用opencv打开摄像头无法关闭的问题