5

我在 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”

有人通过类似的东西吗?

4

1 回答 1

7

你必须小心你的cv2cv进口,这两个工作:

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)
于 2012-06-11T11:15:28.157 回答