$ cd ~
$ wget http://ffmpeg.org/releases/ffmpeg-0.7-rc1.tar.gz
$ tar -xvzf ffmpeg-0.7-rc1.tar.gz
$ cd ffmpeg-0.7-rc1
$ ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libxvid --enable-x11grab --enable-swscale --enable-shared
$ make
$ sudo make install
2. 首先下载相应的opencv版本
http://sourceforge.net/projects/opencvlibrary/files/
或者直接使用命令获取安装包:wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
3. 解压缩包
$ tar xvjf OpenCV-2.4.1.tar.bz
4. 打开opencv目录,创建release文件夹
$ cd OpenCV-2.4.1/
$ mkdir release
5. 预装软件
$ 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
6. 打开release目录,正式编译opencv
$ cd realse
$ 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 ..
安装好的lib文件都会放到/uer/local目录中。
注意:cmake命令后面必须有'..',不然会报错,也可以看一下cmake命令
7. 编译安装opencv
$ make
$ sudo make install
8. 完成opencv的配置
$ sudo vim /etc/ld.so.conf.d/opencv.conf
9. 测试opencv是否可用
$ pkg-config --libs --cflags opencv
如果输出opencv的路径等信息,则opencv可用
10. 运行包中的例子
$ cd ../samples/c
$ chmod a+x build_all.sh
$ ./build_all.sh
$ ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
只要能连接到X server就可以看见美女图片了,如果出现:: cannot connect to X server 按以下命令解决
$ export DISPLAY=:0.0
$ xhost +local:root