Xshell中使用openCV显示图片
1. 问题描述
配置好opencv之后,试着运行了一下自己写的cpp代码,结果报错了,类似于:
OpenCV Error: 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 cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 583
Traceback (most recent call last):
File “show.py”, line 19, in
cv2.imshow(“depth”, im_color)
cv2.error: /io/opencv/modules/highgui/src/window.cpp:583: error: (-2) 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. 包的安装
错误提示中说需要安装libgtk2.0-dev and pkg-config(不过一般后者都安装过了):
sudo apt-get install libgtk2.0-dev pkg-config
安装之后openCV的包需要重新编译,找到openCV的文件夹下的build文件夹(详情可以参考openCV的安装步骤:https://blog.csdn.net/shaojie_45/article/details/117599542)
重新编译并安装
make -j8
sudo make install
之后这一步就完成了
3. Xmanager
Xshell中显示图片需要Xmanager。可惜Xmanager是收费的,推荐去某宝上找个靠谱的店下载一个,之后配置Xshell:
之后就可以正常显示窗口与图片了,如: