-1

code:

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()`

Throws error: "Traceback (most recent call last): File "D:/Python/openCV/Basic_Video/Basic.py", line 4, in with cv2.VideoCapture(0) as cap: AttributeError: __enter__"