1 arch=$(uname -m) 2 if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then 3 flag=1 4 else 5 flag=0 6 fi 7 echo "Installing OpenCV 2.4.9" 8 mkdir OpenCV 9 cd OpenCV 10 echo "Removing any pre-installed ffmpeg and x264" 11 sudo apt-get remove ffmpeg x264 libx264-dev 12 echo "Installing Dependenices" 13 sudo apt-get install libopencv-dev 14 sudo apt-get install build-essential checkinstall cmake pkg-config yasm 15 sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev 16 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev 17 sudo apt-get install python-dev python-numpy 18 sudo apt-get install libtbb-dev 19 sudo apt-get install libqt4-dev libgtk2.0-dev 20 echo "Downloading x264" 21 wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2 22 tar -xvf x264-snapshot-20120528-2245-stable.tar.bz2 23 cd x264-snapshot-20120528-2245-stable/ 24 echo "Installing x264" 25 if [ $flag -eq 1 ]; then 26 ./configure --enable-static 27 else 28 ./configure --enable-shared --enable-pic 29 fi 30 make 31 sudo make install 32 cd .. 33 echo "Downloading ffmpeg" 34 wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2 35 echo "Installing ffmpeg" 36 tar -xvf ffmpeg-0.11.1.tar.bz2 37 cd ffmpeg-0.11.1/ 38 if [ $flag -eq 1 ]; then 39 ./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 40 else 41 ./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 --enable-shared 42 fi 43 make 44 sudo make install 45 cd .. 46 echo "Downloading v4l" 47 wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2 48 echo "Installing v4l" 49 tar -xvf v4l-utils-0.8.8.tar.bz2 50 cd v4l-utils-0.8.8/ 51 make 52 sudo make install 53 cd .. 54 echo "Downloading OpenCV 2.4.9" 55 wget -O opencv-2.4.9.zip http://jaist.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip 56 echo "Installing opencv- 2.4.9" 57 unzip opencv-2.4.9.zip 58 cd opencv-2.4.9 59 mkdir build 60 cd build 61 cmake -D BUILD_EXAMPLES=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON .. 62 sed -i "s/-gencode;arch=compute_11,code=sm_11;-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13;/;/g" `grep -lr ‘arch=compute_11‘ *` 63 sudo make install 64 sudo echo "/usr/local/lib" >> /etc/ld.so.conf 65 sudo ldconfig 66 echo "opencv 2.4.9 ready to be used"
支持保存成run.sh,然后执行chmod +x run.sh,最后运行即可
ubuntu下安装opencv 2.4.9 脚本,支持摄像头和cuda,布布扣,bubuko.com
ubuntu下安装opencv 2.4.9 脚本,支持摄像头和cuda
原文:http://www.cnblogs.com/zhxfl/p/3794593.html