Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv-Python cv2.CV_CAP_PROP_FPS error

Tags:

python

opencv

I'm using opencv 3.2.0 and python 3.5.2 currently. When executing following code:

videoCapture = cv2.VideoCapture(file_path)
fps = videoCapture.get(cv2.CV_CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CV_CAP_PROP_FRAME_WIDTH)),
        int(videoCapture.get(cv2.CV_CAP_PROP_FRAME_HEIGHT)))

I encountered following error:

Traceback (most recent call last):
  File "videoEditor.py", line 29, in <module>
    fps = videoCapture.get(cv2.CV_CAP_PROP_FPS)
AttributeError: module 'cv2.cv2' has no attribute 'CV_CAP_PROP_FPS'

Could anyone tell me what I should do?

like image 316
gasoon Avatar asked Jul 20 '17 13:07

gasoon


1 Answers

In OpenCV 3.2, drop the CV in front of the flag. This should work just fine

videoCapture = cv2.VideoCapture(file_path)
fps = videoCapture.get(cv2.CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),
        int(videoCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
like image 151
eshirima Avatar answered Sep 25 '22 05:09

eshirima