AttributeError: 'cv2.VideoCapture' object has no attribute 'isOpend'

Question:

I have a problem using OpenCV with VS Code
I checked version of OpenCV and Python, but I don’t know what’s wrong.

opencv version is 4.7.0
vscode interpreter is python 3.9.13(‘base’) /opt/anaconda3/bin/python
here is condalist
opencv-contrib-python 4.7.0.72 pypi_0 pypi
opencv-python 4.7.0.72 pypi_0 pypi

this is my code

import cv2
import sys
cap = cv2.VideoCapture(0)

if not cap.isOpend():
    print("Camera is not opend")
    sys.exit(1)
    
while True : 
    res, frame = cap.read()
    
    if not res : 
        print("Camera error")
        break
    
    cv2.imshow("frame", frame)
    
    key = cv2.waitKey(1) & 0xFF
    if key == 27:
        break
cv2.destroyAllWindows()
cap.release()

and the error is:

AttributeError: ‘cv2.VideoCapture’ object has no attribute ‘isOpend’

Asked By: Seonmin Baek

||

Answers:

It’s isOpened– not isOpend. docs. I suppose you were trying to copy this example and copied it wrong (why didn’t you just copy and paste?).

Answered By: user