Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no access to GetCaptureProperty or any similar function in python opencv

Tags:

python

opencv

I tried lot of combinations in opencv 2.3 and 2.4 to get frame count of a video, but without any result. It seems it simply isn't there.

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

'module' object has no attribute 'CV_CAP_PROP_FRAME_COUNT'

Anyone passed something similar?

like image 686
tookanstoken Avatar asked Jun 11 '12 10:06

tookanstoken


1 Answers

You've got to be a little careful of your cv2 and cv imports, both of these work:

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)
like image 102
fraxel Avatar answered Sep 30 '22 14:09

fraxel