【问题标题】:"with" keyword does not work with "cv2.VideoCapture(0)" in python“with”关键字在 python 中不适用于“cv2.VideoCapture(0)”
【发布时间】:2020-04-01 11:10:07
【问题描述】:

代码:

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__"

【问题讨论】:

    标签: python opencv machine-learning computer-vision computer-science


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多