Error Opencv-Python cv2.CV_CAP_PROP_FPS

I am using opencv 3.2.0 and python 3.5.2 currently. When executing the 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 the 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'

Can someone tell me what I should do?

+4
source share
2 answers

In OpenCV 3.2, release CVin front of the flag. That 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)))
+7
source

The answer of Eshirima solved the problem. But for reference only, I want to show you another way to perform these operations, as indicated in the documents: https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get

videoCapture = cv2.VideoCapture(file_path)
width  = int(videoCapture.get(3))
height = int(videoCapture.get(4))
fps = int(videoCapture.get(5))
+1
source

Source: https://habr.com/ru/post/1681878/


All Articles