一、环境配置
Ubuntu 18.04 + Python 3.7 + OpenCV 3.4.2
二、问题描述
/home/wei/anaconda3/envs/GAN/bin/python /home/wei/Documents/ww/tracking/ft.py
Traceback (most recent call last):
File "/home/wei/Documents/ww/tracking/ft.py", line 88, in <module>
cv2.imshow("Tracking", frame)
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'
原文链接:https://blog.csdn.net/wangweiwells/article/details/87871467
由于我当时没有截图,所以只能引用别人的error描述,感谢这位博主。
实际情况是Pycharm的库里最新的OpenCV版本是3.4.2,在cv2.imshow和cv2.waitkey指令都会出现上述错误。
三、解决方法
安装opencv-contrib-python包(暂时认为不需要卸载已经安装的opencv)
pip install opencv-contrib-python
如果出现了下载速度极慢甚至出现长篇红字error的情况(忘记截图了,反正就是下载中途出错),参考我的另一篇文章Ubuntu中pip install安装部分库下载速度慢的参考解决方法更换国内镜像源即可。
补充:
- 如果不行把opencv-python也装了(仅仅是第二个参考源的建议,我当时只装了opencv-contrib-python包)
pip install opencv-python
- 我在实际操作过程中把错误中建议的libgtk2.0-dev和pkg-config两个包也装了,目前尚不清楚是都必要。
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config
四、参考
https://blog.csdn.net/wangweiwells/article/details/87871467
https://stackoverflow.com/questions/50783177/opencv-the-function-is-not-implemented-rebuild-the-library-with-windows
https://zhidao.baidu.com/question/1706449216258017340.html
https://blog.csdn.net/fogxcg/article/details/75808783
———————————————————————————————————————————————
本人新手,在校学生,刚接触ubuntu和python
非常感谢CSDN上各路大佬的帖子,感觉要回馈社区,所以开始写CSDN博客
欢迎咨询,不定期查看回复