Python OpenCV video.get(cv2.CAP_PROP_FPS) returns 0.0 FPS

左心房为你撑大大i 提交于 2020-01-03 08:46:12

问题


This is my video

This is the script to find fps:

import cv2
if __name__ == '__main__' :

    video = cv2.VideoCapture("test.mp4");

    # Find OpenCV version
    (major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')

    if int(major_ver)  < 3 :
        fps = video.get(cv2.cv.CV_CAP_PROP_FPS)
        print "Frames per second using video.get(cv2.cv.CV_CAP_PROP_FPS): {0}".format(fps)
    else :
        fps = video.get(cv2.CAP_PROP_FPS)
        print "Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps)

    video.release(); 

This is the output of the script for this video: Frames per second using video.get(cv2.CAP_PROP_FPS) : 0.0

Why is it returning 0.0? The FPS is 14.0


回答1:


Performing pip install python-opencv fixed the problem and the FPS is correctly detected.



来源:https://stackoverflow.com/questions/49025795/python-opencv-video-getcv2-cap-prop-fps-returns-0-0-fps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!