gpt4 book ai didi

python - cv2 videoCapture 没有属性

转载 作者:行者123 更新时间:2023-12-02 17:17:55 28 4
gpt4 key购买 nike

import cv2

import sys


cpt=0

vidStream=cv2.videoCapture(0)
while True:
ret,frame=vidStream.read()

cv2.imshow("test frame",frame)
cv2.imwrite(r"C:\Users\Abhishek\PycharmProjects\images\0\image%04i.jpg"%cpt,frame)
cpt +=1

if cv2.waitKey(10)==ord('q'):
break
任何人请帮我修复错误
我收到一条错误消息,上面写着“模块 'cv2.cv2' 没有属性 'videoCapture'”和“无法导入 cv2”

最佳答案

1) 不是 cv2.videoCapture(),而是尝试 cv2.VideoCapture()。

Python 2.7.18rc1 (default, Apr  7 2020, 12:05:55) 
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> vid = cv2.videoCapture(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'videoCapture'
>>> vid = cv2.VideoCapture(0) #like that it works fine.
>>>

尝试安装 opencv 使用命令 pip install opencv-pythonpip install opencv-contrib-python ,并检查您是否仍然收到“无法导入 cv2”错误

关于python - cv2 videoCapture 没有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63766879/

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