第二部分:安装OpenCV2.3.1:
1.安装rar解压包:
sudo apt-get install unrar
2.安装GTK库文件及其他所需文件:
sudo apt-get install build-essentiallibgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmakelibswscale-dev libjasper-dev
3.下载x264和ffmpeg所需依赖包:
apt-get install build-essentialcheckinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-devlibopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-devlibx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
4.下载安装gstreamer:
sudo apt-get install libgstreamer0.10-0libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-baselibgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-goodgstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
5.到ftp://ftp.videolan.org/pub/videolan/x264/snapshots/下载x264-snapshot-20120408-2245-stable.并配置,命令如下:cd到解压目录,执行:
./configure --enable-static
make
sudo make install
6.到http://ffmpeg.org/download.html下载安装ffmpeg-0.8.10,解压后cd到解压目录:执行:
./configure --enable-gpl--enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb--enable-libopencore-amrwb --enable-libtheora --enable- libvorbis--enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc--enable-version3 --enable-x11grab
make
sudo make install
7.下载安装v4l (video for linux).从http://www.linuxtv.org/downloads/v4l-utils/下载 v4l-utils-0.8.5.tar.bz2 ,cd到解压目录执行:
make
sudo make install
8.到opencv网站下载opencv-2.3.1.tar.bz2,解压,cd到opencv-2.3.1解压后得目录,依次执行:
mkdir build
cd build
cmake .. (此处是cmake空格后面两点)
9.最后一步,设置环境变量,不执行这一步在运行例程及其他OpenCV程序时就会出现错误:
运行sudo gedit/etc/ld.so.conf.d/opencv.conf,在打开的文件中添加/usr/local/lib,保存并关闭。
运行sudoldconfig
sudo gedit /etc/bash.bashrc
在打开的文件最后加入以下两行:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
10.OpenCV安装完成,下面测试程序:
cd //返回主文件夹
mkdir openCV_samples
cp OpenCV-2.3.1/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
11-参考网址:
1.http://blog.lehu.shu.edu.cn/byman/A349121.html
2.http://blog.csdn.net/xizhibei/article/details/7015494
3.http://blog.sina.com.cn/s/blog_6541b4680100x8cj.html
Ubuntu11.10+OpenCV2.3.1安装全程(二)
最新推荐文章于 2017-12-28 09:37:50 发布