简体   繁体   English

Python OpenCV 的基本命令“Cannot find reference in '__init__'.py

[英]Python OpenCV's basic commands "Cannot find reference in '__init__'.py

While starting a new project, OpenCV just decided to stop working on my PC and laptop.在开始一个新项目时,OpenCV 刚决定停止在我的 PC 和笔记本电脑上工作。 I'm using Python 3.9.我正在使用 Python 3.9。 Basic commands like "imread" and "imshow" aren't working anymore. “imread”和“imshow”等基本命令不再起作用。 I've uninstalled and reinstalled Python and Pycharm.我已经卸载并重新安装了 Python 和 Pycharm。 I've removed the module and reinstalled it... yet and it still won't function properly.我已经删除了模块并重新安装了它......但它仍然无法正确 function。 This is an error I've never seen before.这是我以前从未见过的错误。

import cv2 as cv

img = "Nemo.jpg"
cv.imread(img)
cv.imshow("feesh", img)

Traceback (most recent call last):
  File "C:\Users\ae\PycharmProjects\pythonProject1\main.py", line 5, in <module>
    cv.imshow("feesh", img)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'imshow'
> Overload resolution failed:
>  - mat is not a numpy array, neither a scalar
>  - Expected Ptr<cv::cuda::GpuMat> for argument 'mat'
>  - Expected Ptr<cv::UMat> for argument 'mat'

Cannot find reference Actual error找不到参考实际错误

Thanks!谢谢!

I've also been having this issue with OpenCV 4.6.0.66. OpenCV 4.6.0.66 我也遇到过这个问题。 It's not a perfect solution, but you can roll back to an older version with pip install --force-reinstall --no-cache -U opencv-python==4.5.5.62 .这不是一个完美的解决方案,但您可以使用pip install --force-reinstall --no-cache -U opencv-python==4.5.5.62回滚到旧版本。 There's more discussion/explanation here 这里有更多讨论/解释

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

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