首页 > 代码库 > ubuntu下安装opencv 2.4.9 脚本,支持摄像头和cuda
ubuntu下安装opencv 2.4.9 脚本,支持摄像头和cuda
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 OpenCV10 echo "Removing any pre-installed ffmpeg and x264"11 sudo apt-get remove ffmpeg x264 libx264-dev12 echo "Installing Dependenices"13 sudo apt-get install libopencv-dev14 sudo apt-get install build-essential checkinstall cmake pkg-config yasm15 sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev16 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev17 sudo apt-get install python-dev python-numpy18 sudo apt-get install libtbb-dev19 sudo apt-get install libqt4-dev libgtk2.0-dev20 echo "Downloading x264"21 wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz222 tar -xvf x264-snapshot-20120528-2245-stable.tar.bz223 cd x264-snapshot-20120528-2245-stable/24 echo "Installing x264"25 if [ $flag -eq 1 ]; then26 ./configure --enable-static27 else28 ./configure --enable-shared --enable-pic29 fi30 make31 sudo make install32 cd ..33 echo "Downloading ffmpeg"34 wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz235 echo "Installing ffmpeg"36 tar -xvf ffmpeg-0.11.1.tar.bz237 cd ffmpeg-0.11.1/38 if [ $flag -eq 1 ]; then39 ./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-x11grab40 else41 ./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-shared42 fi43 make44 sudo make install45 cd ..46 echo "Downloading v4l"47 wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz248 echo "Installing v4l"49 tar -xvf v4l-utils-0.8.8.tar.bz250 cd v4l-utils-0.8.8/51 make52 sudo make install53 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.zip56 echo "Installing opencv- 2.4.9"57 unzip opencv-2.4.9.zip58 cd opencv-2.4.959 mkdir build60 cd build61 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 install64 sudo echo "/usr/local/lib" >> /etc/ld.so.conf65 sudo ldconfig66 echo "opencv 2.4.9 ready to be used"
支持保存成run.sh,然后执行chmod +x run.sh,最后运行即可
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。