1. 程式人生 > >Ubuntu14.04 Opencv安裝及常見Error

Ubuntu14.04 Opencv安裝及常見Error

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/lucas/Download/opencv-2.4.13.6/modules/highgui/src/window.cpp, line 501
Traceback (most recent call last):
File “

video.py”, line 191, in
cv2.imshow(‘capture %d’ % i, img)
cv2.error: /home/lucas/Download/opencv-2.4.13.6/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

這個錯誤的大概意思是安裝opencv前有一些庫沒安,所以要先解除安裝乾淨安完相關庫重新安裝opencv即可。

首先找到安裝opencv的build資料夾,依次執行

  1. $ sudo make uninstall
  2. $ cd …
  3. $ sudo rm -r build
  4. $ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
    這一步可能有error
    下面執行如下操作:
  5. sudo apt-get –purge remove opencv-doc opencv-data python-opencv
安裝前更新一下:
 sudo apt-get purge python-opencv
 sudo apt-get update
 sudo apt-get upgrade

最關鍵的一步,

不管3721直接把所有相關庫一次性安裝完
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev

sudo apt-get install python-opencv

接下來安其他包建議採用以下方式:

sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python-matplotlib
sudo apt-get install python-pandas
sudo apt-get install python-sklearn