简体   繁体   English

python opencv cv2.waitkey 错误

[英]python opencv cv2.waitkey error

i'm trying to test the following code of the getting started page :我正在尝试测试入门页面的以下代码:

import numpy as np
import cv2   
img = cv2.imread('test.jpg', 0)
cv2.imshow('image', img)
cv2.waitkey(0)&0xFF
cv2.destroyAllWindows()

But i got this error:但我收到了这个错误:

init done 
opengl support available 
Traceback (most recent call last):
  File "showimg.py", line 5, in <module>
    cv2.waitkey(0)&0xFF
AttributeError: 'module' object has no attribute 'waitkey'
Violación de segmento

I executed the examples that comes with the opencv installation, and they run correctly.我执行了 opencv 安装附带的示例,它们运行正常。 Also, the last example that use the Matplotlib works fine.此外,使用 Matplotlib 的最后一个示例工作正常。

¿Any idea of the error?, ¿any suggestion? ¿对错误有任何想法吗?,任何建议?

AttributeError: 'module' object has no attribute 'waitkey' AttributeError: 'module' 对象没有属性 'waitkey'

Try cv2.waitKey in place of cv2.waitkey .尝试cv2.waitKey代替cv2.waitkey Capitalization counts.大小写很重要。

cv2.waitKey()

This syntax works.此语法有效。 In the open parentheses add time.在左括号中添加时间。

尝试使用waitKey() 而不是waitkey(),效果很好。

'module' object has no attribute 'waitkey' 

For solving this problem you should use this code:要解决此问题,您应该使用以下代码:

在此处输入图片说明

'waitKey' with capital K, it will solve your problem. 'waitKey' 与大写 K,它将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM