OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES错误 [英] OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES error
问题描述
目前,我使用opencv 3.1.0,执行以下代码时遇到以下错误:
Currently, I am use opencv 3.1.0, and I encountered the following error when executing the following code:
post_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES)
我收到以下错误消息:
文件videoOperation.py,第37行,
pos_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES)
AttributeError:'module'对象没有属性'CV_CAP_PROP_POS_FRAMES '
File "videoOperation.py", line 37, in pos_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES) AttributeError: 'module' object has no attribute 'CV_CAP_PROP_POS_FRAMES'
使用OpenCV 2.X时,代码应采用以下格式编写:
The code should be write in the following format when using OpenCV 2.X:
post_frame = cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
请参阅< a href =https://stackoverflow.com/questions/30013009/opencv-3-0-0-dev-python-bindings-not-working-properly> opencv 3.0.0-dev python绑定无法正常工作,我知道
在opencv3.0中删除了cv2.cv子模块,还修改了一些常量
the cv2.cv submodule got removed in opencv3.0, also some constants were changed
但cv2.CV_CAP_PROP_POS_FRAMES对我不起作用,那么我想做什么?
But the cv2.CV_CAP_PROP_POS_FRAMES didn't work for me, So what and i suppose to do?
推荐答案
尝试输入此而不是你的:
Try typing this instead of yours:
post_frame = cap.get(1) #CAP_PROP_POS_FRAMES = 1
如果你在Python shell中输入 help('cv2')
,你将会找到一些语法修改。这些都不是数据
。只是一个例子。
If you type help('cv2')
in the Python shell you will find some modifications to the syntax.These are not all the Data
. Just an illustration.
CAP_PROP_PAN = 33
CAP_PROP_POS_AVI_RATIO = 2
CAP_PROP_POS_FRAMES = 1
CAP_PROP_POS_MSEC = 0
CAP_PROP_PVAPI_BINNINGX = 304
CAP_PROP_PVAPI_BINNINGY = 305
CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302
这篇关于OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!