寻求相同的帧位置,但获得不同的数据

时间:2013-03-27 13:40:08

标签: python opencv

我想从一些起始帧开始查询视频中间的帧。关注OpenCV Seek Function/Rewind后,我使用CV_CAP_PROP_POS_FRAMES

为了验证它是否按预期工作,我寻找第10帧并从图像中打印切片。然后我再次寻找第10帧并打印相同的切片。

In [1]: import cv

In [2]: capture = cv.CaptureFromFile('T35V1.MOV')

In [3]: cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, 10)
Out[3]: 1

In [4]: np.asarray(cv.GetMat(cv.QueryFrame(capture)))[100] # an arbitrary slice
Out[4]: 
array([[ 36, 104, 120],
       [ 36, 104, 120],
       [ 36, 107, 123],
       ..., 
       [ 50, 114, 136],
       [ 54, 115, 136],
       [ 55, 116, 137]], dtype=uint8)

In [5]: cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, 10)
Out[5]: 1

In [6]: np.asarray(cv.GetMat(cv.QueryFrame(capture)))[100]
Out[6]: 
array([[ 32, 107, 119],
       [ 32, 107, 119],
       [ 35, 109, 124],
       ..., 
       [ 42, 114, 135],
       [ 47, 118, 139],
       [ 50, 121, 142]], dtype=uint8)

数据不一致。我在滥用这个吗?

相关:http://code.opencv.org/issues/481 这个OpenCV用户在C ++中发现设置和获取属性两次可以解决这个问题。对我而言,无论是使用cv还是cv2,问题仍然存在。

0 个答案:

没有答案