1.首先在终端运行下列命令进行必要的编译环境安装。
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev cmake libswscale-dev libjasper-dev
2.下载OpenCV-2.4.3
# tar -jxvf OpenCV-2.4.3.tar.bz2
# cd OpenCV-2.4.3
3.终端运行
# mkdir build
# cd build
# cmake ../
4.依次运行
# make
# sudo make install
5.配置必要的库
# 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
6.运行测试程序
# mkdir opencv_samples
# cp OpenCV-2.4.3/samples/c/* opencv_samples
# cd opencv_samples/
# chmod +x build_all.sh
# ./build_all.sh
# ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
出现一个人脸图像 成功~~~