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:
  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 
$ 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:
  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 .. 
$ 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 ..
  1. $ make 
  2. $ sudo make install 
$ make
$ sudo make install

Set environment:
  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 
$ sudo echo "/usr/local/lib" >> /etc/ld.so.conf
$ sudo ldconfig
$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Build samples
  1. $ cd opencv-2.4.7/samples/c 
  2. $ ./build_all.sh 
$ cd opencv-2.4.7/samples/c
$ ./build_all.sh

Run a sample:
  1. $ ./delaunay 
$ ./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:
  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 
$ 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:
  1. sudo apt-get install python-dev 
sudo apt-get install python-dev

--------

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

Solution:
  1. $ sudo apt-get install libstdc++5 
$ 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
  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 
$ 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:
  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 
$ 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:
  1. sudo apt-get install gtk2-engines-pixbuf 
sudo apt-get install gtk2-engines-pixbuf


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值