【问题标题】:python AttributeError opencvpython AttributeError opencv
【发布时间】:2020-02-03 02:29:05
【问题描述】:

我是 opencv 的新手,我试图简单地显示图像,但是对于每个 cv2 函数,我都会遇到相同的错误,(AttributeError)

我已经安装了 pip install opencv-contrib-python 女巫被建议解决这个问题但没有改变,

import cv2
img = cv2.imread ("C:\\Users\\Astroid\\Desktop\\desktop backround pics\\560736.jpg", 1)
print(img)
cv2.imshow("560736",img)
cv2.WaitKey(2000)
cv2.DestroyAllWindows()

完全错误是。

Traceback(最近一次调用最后一次): 文件“C:/Users/Astroid/.PyCharmCE2019.1/config/scratches/scratch.py​​”,第 6 行,在 cv2.WaitKey(20000) AttributeError: 模块 'cv2.cv2' 没有属性 'WaitKey'

【问题讨论】:

    标签: python opencv attributeerror


    【解决方案1】:

    方法使用小写:[docs]

    retval = cv.waitKey([, delay])
    

    【讨论】:

    • thx,这适用于 waitkey 但是我说所有 cv2 函数都发生了相同的 AttributeError,在我实现了你的代码行之后,它显示了图像但是程序以 Traceback 结束(最近的调用最后):文件“C:/Users/Astroid/.PyCharmCE2019.1/config/scratches/scratch.py​​”,第 7 行,在 cv2.DestroyAllWindows() AttributeError: module 'cv2.cv2' has no attribute' DestroyAllWindows',当我在 reasized = cv2.reasize(img, (800,600)) 中实现这一行时,同样发生了
    • cv2 的命名约定是第一个字母小写,然后是驼峰式,所以它应该是 destroyAllWindows()
    猜你喜欢
    • 2019-02-06
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 1970-01-01
    相关资源
    最近更新 更多