1.报错问题:
cv2.imshow("img01", image)
cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/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'
2. Ubuntu环境 :python3.6 , anaconda3,opencv3.4.2
3.解决办法:
pip install opencv-contrib-python
接着就会下载了,但下载太慢了,会中断报错
ubuntu已经是国内源了,把pip也换成国内源:
mkdir ~/.pip
cd ~/.pip
touch pip.conf
sudo nano ~/.pip/pip.conf
打开pip.conf 文件后,添加如下内容:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
Ctrl+O,enter保存,Ctrl+X退出。
更新一下:
sudo apt-get update
再次安装,速度会很快了
这时运行项目代码没有报错,cv2.imshow()就解决了。