现在的位置: 首页 > 综合 > 正文

Install opencv-2.4.7 in Ubuntu 11.10 with Qt support

2013年06月06日 ⁄ 综合 ⁄ 共 5714字 ⁄ 字号 评论关闭

结合自己在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:

$ sudo apt-get install python-dev libcv-dev libcvaux-dev libhighgui-dev 
$ sudo apt-get install libtbb-dev  libqt4-dev libqt4-opengl-dev libjpeg-dev libtiff4-dev 
$ 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
$ 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:

$ tar -axvf opencv-2.4.7.tar.gz
$ cd opencv-2.4.7
$ mkdir release
$ cd release
$ 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 ..
$ make
$ sudo make install

Set environment:

$ sudo echo "/usr/local/lib" >> /etc/ld.so.conf
$ sudo ldconfig
$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Build samples

$ cd opencv-2.4.7/samples/c
$ ./build_all.sh

Run a sample:

$ ./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:

$ cd ~
$ wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Linux-i386.sh
$ chmod +x cmake-2.8.10.2-Linux-i386.sh
$ ./cmake-2.8.10.2-Linux-i386.sh
then you will a new fold named "cmake-2.8.10.2-Linux-i386" in ~ directory, and  add the path to PATH environment
$ export PATH=~/cmake-2.8.10.2-Linux-i386/bin:$PATH
$ cmake --version
cmake version 2.8.10.2

--------

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

Solution:

sudo apt-get install python-dev

--------

Problem:

$ python
python: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

Solution:

$ 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

$ python -V
Python 2.6.6
$ curl -kL https://raw.github.com/utahta/pythonbrew/master/pythonbrew-install | bash
$ . $HOME/.pythonbrew/etc/bashrc
$ pythonbrew install 2.7.2
$ pythonbrew switch 2.7.2
Switched to Python-2.7.2
$ python -V
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:

$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/share/pkgconfig
$ pkg-config --cflags --libs opencv
-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:

sudo apt-get install gtk2-engines-pixbuf

抱歉!评论已关闭.