qt
1.sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
2.连接MySQL数据库,需要安装连接MySQL的驱动程序:
sudo apt-get install libqt4-sql-mysql
opencv
1.sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev(cmake-gui,)
1)在安装OpenCV前需要安装的软件包有
GCC4.4.X or later,可通过命令sudo apt-get install build-essential安装
CMake2.6 or later
SVN客户端
GTK+2.Xor higher, including headers(libgtk2.0-dev)
pkgconfig
Python2.6 or later and Numpy 1.5 or later with developerpackages(python-dev, python-numpy)
ffmpegor libav development packages: libavcodec-dev, libavformat-dev,libswsacle-dev
[可选]libdc13942.x
[可选]libjpeg-dev,libpng-dev, libtiff-dev, libjasper-dev
所有的软件包都可在终端安装或者通过Synaptic软件管理器。
终端安装依赖项:
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 libeigen2-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
2)下载最新版OpenCV
打开网页:http://sourceforge.net/projects/opencvlibrary
下载安装包OpenCV-2.4.2.tar.bz2
sudo tar jxvf OpenCV-2.4.2.tar.bz2 -C /usr/local/
cd /usr/local/
sudo mv OpenCV-2.4.2 opencv
cd opencv
mkdir release
cd release
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -DBUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make
sudo make install
3)安装后的配置
添加库的路径
sudo gedit /etc/ld.so.conf.d/opencv.conf
添加内容
/usr/local/lib
在终端输入命令
sudo ldconfig
设置环境变量
sudo gedit /etc/bash.bashrc
在文件最后加入以下两行并保存:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
此时重启Ubuntu或重新登录账户,使得OpenCV安装生效。
4)测试OpenCV自带例程
编译程序:
cd /usr/local/opencv/samples/c
chmod +x build_all.sh./build_all.sh
测试:gcc `pkg-config opencv --libs --cflags opencv` -o main main.c
如果出现:
opencv1.c:(.text+0×23): undefined reference to `cvLoadImage’
opencv1.c:(.text+0×36): undefined reference to `cvNamedWindow’
opencv1.c:(.text+0×47): undefined reference to `cvShowImage’
opencv1.c:(.text+0×51): undefined reference to `cvWaitKey’
opencv1.c:(.text+0x5d): undefined reference to `cvReleaseImage’
opencv1.c:(.text+0×67): undefined reference to `cvDestroyWindow’
collect2: ld returned 1 exit status
则用:gcc `pkg-config --cflags opencv` -o main main.c `pkg-config --libs opencv`
OpenCV installation for Ubuntu 12.04
To install OpenCV 2.4.2 or 2.4.3 on the Ubuntu 12.04 operating system, first install a developer environment to build OpenCV.
sudo apt-get -y install build-essential cmake pkg-config
Install Image I/O libraries
sudo apt-get -y install libjpeg62-dev
sudo apt-get -y install libtiff4-dev libjasper-dev
Install the GTK dev library
sudo apt-get -y install libgtk2.0-dev
Install Video I/O libraries
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
Optional - install support for Firewire video cameras
Optional - install video streaming libraries
sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
Optional - install the Python development environment and the Python Numerical library
sudo apt-get -y install python-dev python-numpy
Optional - install the parallel code processing library (the Intel tbb library)
sudo apt-get -y install libtbb-dev
Optional - install the Qt dev library
sudo apt-get -y install libqt4-dev
Now download OpenCV 2.4 to wherever you want to compile the source.
mkdir xxx
cd xxx
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/Op...
or
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.3/Op...
tar -xvf OpenCV-2.4.*.tar.bz2
Create and build directory and onfigure OpenCV with cmake. Don't forget the .. part at the end of cmake cmd !!
cd OpenCV-2.4.*
mkdir build
cd build
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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON
-D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
Now compile it
make
And finally install OpenCV
sudo make install
Tags:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local
-DWITH_TBB=ON -DBUILD_NEW_PYTHON_SUPPORT=ON -DWITH_V4L=ON
-DINSTALL_C_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON
-DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON ..