Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在openCV中使用waitkey()时出错_Python_Image_Python 2.7_Opencv_Image Processing - Fatal编程技术网

Python 在openCV中使用waitkey()时出错

Python 在openCV中使用waitkey()时出错,python,image,python-2.7,opencv,image-processing,Python,Image,Python 2.7,Opencv,Image Processing,我一直在编写一个非常简单的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'):

我一直在编写一个非常简单的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'
第11行,在
如果cv2.waitkey(0)&0xff==ord('q'):
AttributeError:“模块”对象没有属性“waitkey”

出路是什么?我使用的是Python 2.7.13和openCV 2.4.10

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

在cv2.waitKey()中K是大写的,写


只需将cv2.waitkey(1)替换为cv2.waitKey(1)

@D.Mitra您可以将此答案标记为已验证的解决方案
if (cv2.waitKey(1) & 0xff) == ord('q'):
    break