Ubuntu12.04安装OpenCV 2.4.1

1. 
sudo apt-get update 
sudo apt-get upgrade

2.只需在终端里粘贴一下,很简单,此步骤安装的是必备的包文件: 
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

3.下载OpenCV2.4.1源码包: 
cd ~ 
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2 
tar -xvf OpenCV-2.4.1.tar.bz2 
cd OpenCV-2.4.1

4.使用cmake生成makefile文件 
mkdir build 
cd build 
cmake -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 ..

5.编译安装 
make 
sudo make install

6.配置OpenCV 
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加在末尾

7.重启或注销一下



你可能感兴趣的:(ubuntu,opencv)