Ask Your Question

Cpp's profile - activity

2019-10-11 13:29:35 -0600 received badge  Notable Question (source)
2019-06-11 11:29:53 -0600 received badge  Popular Question (source)
2012-08-03 16:16:14 -0600 received badge  Student (source)
2012-07-31 13:39:04 -0600 received badge  Scholar (source)
2012-07-31 13:39:00 -0600 commented answer After setting capture property, reading the property returns 0.0

Thanks! That was really helpful.

2012-07-31 12:50:49 -0600 asked a question After setting capture property, reading the property returns 0.0

Helpful openCVers-

If I set the capture property like this:

cv.SetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES,40)

then read it like this:

cv.GetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES)

I get 0.0, not 40. The next time I query it, the frame is 37 or 49!

Here is my test script:

#testify.py  import cv

VideoName= "target.avi"  TempName= "temp.tiff"  Capture= cv.CaptureFromFile(VideoName)
MaxFrames= cv.GetCaptureProperty(Capture,cv.CV_CAP_PROP_FRAME_COUNT)

for x in range(10):
    print cv.GetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES)
    CurrentFrame = cv.QueryFrame(Capture)

cv.SetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES,40)

for x in range(10):     
    print cv.GetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES)  
    CurrentFrame = cv.QueryFrame(Capture)

cv.SetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES,40)

for x in range(10):
     print cv.GetCaptureProperty(Capture,cv.CV_CAP_PROP_POS_FRAMES)
     CurrentFrame = cv.QueryFrame(Capture)

my output is:

0.0
0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
0.0
49.0
50.0
51.0
52.0
53.0
54.0
55.0
56.0
57.0
0.0
37.0
38.0
39.0
40.0
41.0
42.0
43.0
44.0
45.0

So my question is: why is the first frame always 0.0? and after setting the frame to 40, why does it jump to 49 and 37?

Thanks!

--Cpp