gpt4 book ai didi

python - OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES 错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:43 30 4
gpt4 key购买 nike

我目前使用的是opencv 3.1.0,执行以下代码时遇到如下错误:

post_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES)

我收到以下错误消息:

文件“videoOperation.py”,第 37 行,位于 pos_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES)AttributeError:“模块”对象没有属性“CV_CAP_PROP_POS_FRAMES”

使用OpenCV 2.x时,代码应按以下格式编写:

post_frame = cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)

来自 opencv 3.0.0-dev python bindings not working properly , 我知道

the cv2.cv submodule got removed in opencv3.0, also some constants were changed

但是 cv2.CV_CAP_PROP_POS_FRAMES 对我不起作用,那我该怎么办?

最佳答案

试着输入这个:

post_frame = cap.get(1) #CAP_PROP_POS_FRAMES = 1

如果您在 Python shell 中键入 help('cv2'),您会发现语法有一些修改。

output truncated

...
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
...

关于python - OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38563079/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com