ubuntu 11.04安装OpenCV
by Elton on 七.27, 2011, under C/C++, Linux
Step 1:安装必要的依赖包
sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
Step 2:安装ffmpeg
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
Step 3:安装OpenCV 2.3
cd ~ wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3/OpenCV-2.3.0.tar.bz2 tar -xvf OpenCV-2.3.0.tar.bz2 cd OpenCV-2.3.0/ mkdir release cd releasecmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_TBB=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON .. make sudo make intall
Step 4:添加库的路径
sudo vim /etc/ld.so.conf.d/opencv.conf
加入:
/usr/local/lib
更新系统库
sudo ldconfig
设置环境变量
sudo vim /etc/environment
加入
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
至此,OpenCV的设置都完成了。
Step 5:测试
进入OpenCV源代码目录中的sample
cd ~/OpenCV-2.3.0/samples/c chmod +x build_all.sh ./build_all.sh