windows使用opencv报异常处理

使用opencv调用方法时,报异常:

cv.imshow('imshow', img)

cv2.error: OpenCV(3.4.1-dev) /home/yhc/workspace/tvm/opencv/opencv-src/modules/highgui/src/window.cpp:632: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’

使用,直接把国内源都贴上了:这个先把组件卸载了,再重新安装
 

pip uninstall opencv-contrib-python

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/  opencv-contrib-python

当然之后会报这个错误:
Traceback (most recent call last):
  File "D:/pycharm/ten-test/leidianModel/leidianMethod.py", line 5, in
    import cv2 as cv
  File "D:\python\lib\site-packages\cv2\__init__.py", line 9, in
    from .cv2 import _registerMatType
ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (D:\python\lib\site-packages\cv2\cv2.cp37-win_amd64.pyd)

通过重新

pip uninstall opencv-python-headless

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/  opencv-python-headless

则可正常使用

如果以上操作还不行,就是opencv版本与组件不匹配,则重复第一步操作的卸载opencv-contrib-python操作,然后把opencv-python直接卸载了

pip uninstall opencv-python
再重新安装

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ opencv-python

安装完成后,再重新安装第一步,之后方法正常使用不报错

windows使用opencv报异常处理_第1张图片

 

你可能感兴趣的:(Python,opencv,人工智能,计算机视觉)