代码:
import cv2
import numpy as np
with cv2.VideoCapture(0) as cap:
while True:
ret, frame = cap.read()
cv2.imshow("Title", frame)
if cv2.waitKey(1):
break
cv2.destroyAllWindows()`
抛出错误: “ 回溯(最近通话最近): 文件“ D:/Python/openCV/Basic_Video/Basic.py”,第4行,在 以cv2.VideoCapture(0)为上限: AttributeError:__enter __ “
答案 0 :(得分:1)