Install opencv-2.4.7 in Ubuntu 11.10 with Qt support

请访问原文地址:http://blog.csdn.net/ajaxhe/article/details/16986451

结合自己在Ubuntu 11.10下安装opencv-2.4.7遇到的问题,整理如下:

Install opencv-2.4.7 in Ubuntu 11.10 with Qt support

ref-link: http://www.cnblogs.com/steven-blog/archive/2013/04/27/3046357.html
ref-link: http://www.cnblogs.com/keyemb/p/3233966.html

Requirement:
python-2.7.2+
cmake-2.8.8+

Pre-install:
[plain] view plain copy print ?
  1. $ sudo apt-get install python-dev libcv-dev libcvaux-dev libhighgui-dev
  2. $ sudo apt-get install libtbb-dev libqt4-dev libqt4-opengl-dev libjpeg-dev libtiff4-dev
  3. $ sudo apt-get install yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
  4. $ sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg

Install command:
[plain] view plain copy print ?
  1. $ tar -axvf opencv-2.4.7.tar.gz
  2. $ cd opencv-2.4.7
  3. $ mkdir release
  4. $ cd release
  5. $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
[plain] view plain copy print ?
  1. $ make
  2. $ sudo make install

Set environment:
[plain] view plain copy print ?
  1. $ sudo echo "/usr/local/lib" >> /etc/ld.so.conf
  2. $ sudo ldconfig
  3. $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Build samples
[plain] view plain copy print ?
  1. $ cd opencv-2.4.7/samples/c
  2. $ ./build_all.sh

Run a sample:
[plain] view plain copy print ?
  1. $ ./delaunay

Notic:
1. BUILD_PYTHON_SUPPORT is for old opencv version, when you compiling opencv-2.4.7, you should use BUILD_NEW_PYTHON_SUPPORT
2. If you haven't install independens, you will get the following errors or warning

-------

Problem:
Make Error at /home/bbs/Documents/opencv/opencv-2.4.7/cmake/cl2cpp.cmake:50 (string):
string does not recognize sub-command MD5

Solution:
This project requires version 2.8.8 of CMake. I am running version 2.8.5.

How to update cmake in Ubuntu11.10?
ref-link: http://askubuntu.com/questions/263826/cmake-2-8-9-on-ubuntu-10-04

Enter the folloe commands:
[plain] view plain copy print ?
  1. $ cd ~
  2. $ wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Linux-i386.sh
  3. $ chmod +x cmake-2.8.10.2-Linux-i386.sh
  4. $ ./cmake-2.8.10.2-Linux-i386.sh
  5. then you will a new fold named "cmake-2.8.10.2-Linux-i386" in ~ directory, and add the path to PATH environment
  6. $ export PATH=~/cmake-2.8.10.2-Linux-i386/bin:$PATH
  7. $ cmake --version
  8. cmake version 2.8.10.2

--------

Prblem:
Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS) (Required is at least version "2.7.2")

Solution:
[plain] view plain copy print ?
  1. sudo apt-get install python-dev

--------

Problem:
[plain] view plain copy print ?
  1. $ python
  2. python: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

Solution:
[plain] view plain copy print ?
  1. $ sudo apt-get install libstdc++5

---------

Problem:
update python-2.4 to python-2.7.2

Solution:
ref-link: http://stackoverflow.com/questions/5233536/python-2-7-on-ubuntu

How update python in Ubuntu 11.10
[plain] view plain copy print ?
  1. $ python -V
  2. Python 2.6.6
  3. $ curl -kL https://raw.github.com/utahta/pythonbrew/master/pythonbrew-install | bash
  4. $ . $HOME/.pythonbrew/etc/bashrc
  5. $ pythonbrew install 2.7.2
  6. $ pythonbrew switch 2.7.2
  7. Switched to Python-2.7.2
  8. $ python -V
  9. Python 2.7.2

----------

Problem:
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_PYTHON_SUPPORT

Solution:
ref-link: http://stackoverflow.com/questions/8510972/building-opencv-2-3-1-with-python-2-7-support-in-ubuntu-11-10-64bit
It looks like you're using an old install guide. Use BUILD_NEW_PYTHON_SUPPORT instead.
change the cmake command line
from:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
to:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..

--------

Problem:
pkg-config cann't find the opencv setting
$ pkg-config opencv --cflags --libs
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

Solution:
[plain] view plain copy print ?
  1. $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/share/pkgconfig
  2. $ pkg-config --cflags --libs opencv
  3. -I/usr/local/include/opencv -I/usr/local/include /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl

--------

Problem:
opencv application runtime 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 cvNamedWindow, file /home/bbs/Documents/opencv/opencv-2.4.7/modules/highgui/src/window.cpp, line 483
terminate called after throwing an instance of 'cv::Exception'
what(): /home/bbs/Documents/opencv/opencv-2.4.7/modules/highgui/src/window.cpp:483: 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 cvNamedWindow

Aborted

Solution:
Make sure you have installed a graphic lib(gtk+2.0 or Qt) at least. If you choose Qt, just using follow command:
$ sudo apt-get install libqt4-dev
And reconfigure the cmake, make sure you have switch on WITH_QT:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
Then recompile and reinstall opencv.

-------

Problem:
When you running opencv application with Qt Interface, Terminal show:
Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap"

Solution:
[plain] view plain copy print ?
  1. sudo apt-get install gtk2-engines-pixbuf


你可能感兴趣的:(Install opencv-2.4.7 in Ubuntu 11.10 with Qt support)