我在opencv 2.3和2.4中尝试了很多组合以获取视频的帧数,但没有任何结果。似乎根本不存在。
stream = cv.VideoCapture(avsfilename) #stream.isOpened() returns True, everything's ok
framecount = cv.GetCaptureProperty(stream, CV_CAP_PROP_FRAME_COUNT) #no
framecount = cv.GetCaptureProperty(stream, cv.CV_CAP_PROP_FRAME_COUNT) #no
framecount = stream.get(cv.CV_CAP_PROP_FRAME_COUNT) #no
framecount = stream.get(CV_CAP_PROP_FRAME_COUNT) #no
“模块”对象没有属性“CV_CAP_PROP_FRAME_COUNT”
有人通过类似的东西吗?
最佳答案
您必须小心cv2
和cv
的导入,这两种方法都可以:
import cv2
import cv2.cv as cv
#Using cv2:
stream = cv2.VideoCapture(filename)
print stream.get(cv.CV_CAP_PROP_FRAME_COUNT)
#using cv:
stream = cv.CaptureFromFile(filename)
print cv.GetCaptureProperty(stream, cv.CV_CAP_PROP_FRAME_COUNT)
关于python - 无法访问GetCaptureProperty或python opencv中的任何类似函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10978768/