gpt4 book ai didi

python - 在 openCV 中使用 waitkey() 时出错

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

我一直在研究一个非常简单的 python 代码来获取视频输入。

import cv2
import numpy as np

#Capturing video
cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read() #Ret returns whether it's true or false
cv2.imshow('Image',frame)

if cv2.waitkey(1) & 0xff == ord('q'):
break
cap.release()
cv2.destroyAllWindows()

但是,在执行时,它显示了这样的错误...

line 11, in <module>
if cv2.waitkey(0) & 0xff == ord('q'):
AttributeError: 'module' object has no attribute 'waitkey'

出路何在?我正在使用 Python 2.7.13 和 openCV 2.4.10。

最佳答案

cv2.waitKey() 而不是 cv2.waitkey()

关于python - 在 openCV 中使用 waitkey() 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43449810/

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