天天看點

Xshell中使用openCV顯示圖檔1. 問題描述2. 包的安裝3. Xmanager

Xshell中使用openCV顯示圖檔

  • 1. 問題描述
  • 2. 包的安裝
  • 3. Xmanager

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:

Xshell中使用openCV顯示圖檔1. 問題描述2. 包的安裝3. Xmanager
Xshell中使用openCV顯示圖檔1. 問題描述2. 包的安裝3. Xmanager

之後就可以正常顯示視窗與圖檔了,如:

Xshell中使用openCV顯示圖檔1. 問題描述2. 包的安裝3. Xmanager

繼續閱讀