Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

AttributeError: 'module' object has no attribute 'CV_CAP_PROP_FRAME_HEIGHT'

So i am using OpenCv 3.3, python 2.7 and PyQt and i get this Attribute Error which i have no idea how to fix. This is my Code:

import numpy as np
import cv2
import sys
sys.path.append('/home/pi/.virtualenvs/cv/lib/python2.7/site-packages/usr/local/lib/python2.7/site-packages')

cap = cv2.VideoCapture(0)

while(True):
        ret, frame = cap.read()

cap.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, 1080)
cap.set(cv2.CV_CAP_PROP_FRAME_WIDTH, 1920)
    # Display the resulting frame
    cv2.imshow('frame',frame)
    cv2.namedWindow('frame', cv2.CV_WINDOW_AUTOSIZE)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break#Display resulting frame

#when everything done, release the capture
cap.release()
cv2.destroyAllWindows()

If it makes any difference i used a virtual enviroment to install OpenCv and i also tried to use CAP_PROP_FRAME_HEIGHT but it also didnt get recognized and returns the same error.

AttributeError: 'module' object has no attribute 'CV_CAP_PROP_FRAME_HEIGHT'

So i am using OpenCv 3.3, python 2.7 and PyQt and i get this Attribute Error which i have no idea how to fix. This is my Code:

import numpy as np
import cv2
import sys
sys.path.append('/home/pi/.virtualenvs/cv/lib/python2.7/site-packages/usr/local/lib/python2.7/site-packages')

cap = cv2.VideoCapture(0)

while(True):
        ret, frame = cap.read()

cap.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, 1080)
cap.set(cv2.CV_CAP_PROP_FRAME_WIDTH, 1920)
    # Display the resulting frame
    cv2.imshow('frame',frame)
    cv2.namedWindow('frame', cv2.CV_WINDOW_AUTOSIZE)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break#Display resulting frame

#when everything done, release the capture
cap.release()
cv2.destroyAllWindows()

If it makes any difference i used a virtual enviroment to install OpenCv and i also tried to use CAP_PROP_FRAME_HEIGHT but it also didnt get recognized and returns the same error.

AttributeError: 'module' object has no attribute 'CV_CAP_PROP_FRAME_HEIGHT''CAP_PROP_FRAME_HEIGHT'

So i am using OpenCv 3.3, python 2.7 and PyQt and i get this Attribute Error which i have no idea how to fix. This is my Code:

import numpy as np
import cv2
import sys
sys.path.append('/home/pi/.virtualenvs/cv/lib/python2.7/site-packages/usr/local/lib/python2.7/site-packages')

cap = cv2.VideoCapture(0)

while(True):
        ret, frame = cap.read()

cap.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
cap.set(cv2.CV_CAP_PROP_FRAME_WIDTH, cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
    # Display the resulting frame
    cv2.imshow('frame',frame)
    cv2.namedWindow('frame', cv2.CV_WINDOW_AUTOSIZE)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break#Display resulting frame

#when everything done, release the capture
cap.release()
cv2.destroyAllWindows()

If it makes any difference i used a virtual enviroment to install OpenCv and i also tried to use CAP_PROP_FRAME_HEIGHT CV_CAP_PROP_FRAME_HEIGHT but it also didnt get recognized and returns the same error. error.