ubuntu下opencv使用cvNamedWindow()和cvShowImage()出錯的解決方法


重裝系統和opencv,編譯運行顯示一副圖像的程序,報錯如下

1 liurf@liurf-Lenovo-G470:~/WorkSpace/slambook-master/ch5/imageBasics$ ./imageBasics ubuntu.png 
2 圖像寬為1200,高為674,通道數為3
3 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 /home/liurf/opencv/modules/highgui/src/window.cpp, line 501
4 terminate called after throwing an instance of 'cv::Exception'
5   what():  /home/liurf/opencv/modules/highgui/src/window.cpp:501: 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
6 
7 已放棄 (核心已轉儲)

根據提示安裝gtk2.0和pkg-config,運行不了,仔細看。

我們進入到opencv源代碼庫,找到highgui庫下面,具體路徑“/home/liurf/opencv/modules/highgui”,依次運行“cmake .”,"make -j4","sudo make install",之后再進入我們的程序下面重新編譯運行就一切正常了。

每次編譯opencv都會出現,解決了就沒管它,還是記下來省得百度浪費時間。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM