Caffe 安裝OpenCV-2.4.13
阿新 • • 發佈:2019-01-09
有一段時間沒寫部落格了,主要是有一段時間沒弄Ubuntu的Caffe配置了。
最近NVIDIA把驅動啥的都升級到了CUDA 8.0版本,安裝OpenCV的時候會出現版本不相容的問題。相信大家的OpenCV安裝包都是Github上的大神寫的,大神的安裝包裡面的opencv_latest.sh指令碼原來安裝的是OpenCV 2.4.13,現在安裝的是OpenCV 3 了。但是想安裝OpenCV 2 的話發現Install-OpenCV-master/Ubuntu/2.4/這個資料夾之下的安裝指令碼最新的是OpenCV 2.4.10。
OpenCV 2.4.9和OpenCV 2.4.10 和CUDA 8.0有相容問題,安裝的時候各種報錯,告訴你各種東西沒有宣告,非常麻煩,但是OpenCV 2.4.13是OpenCV 2 唯一的一個2016年釋出的版本,和CUDA 8.0沒有相容問題。
那麼,如何安裝OpenCV 2.4.13呢?當然要自己寫指令碼,程式碼附在下面,我不會說我是複製了opencv2_4_10.sh,然後把裡面的2.4.10改成了2.4.13。
1.新建檔案opencv2_4_13.sh:
gedit opencv2_4_13.sh
2.把下面的程式碼複製進去。
3.把opencv2_4_13.sh這個檔案放在Install-OpenCV-master/Ubuntu/2.4/ 這個目錄下面。
4.sudo sh ./opencv2_4_13.sh
5."OpenCV 2.4.13 ready to be used"
opencv2_4_13.sh:
arch=$(uname -m) if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then flag=1 else flag=0 fi echo "Installing OpenCV 2.4.13" mkdir OpenCV cd OpenCV echo "Removing any pre-installed ffmpeg and x264" sudo apt-get -y remove ffmpeg x264 libx264-dev echo "Installing Dependenices" sudo apt-get -y install libopencv-dev sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm sudo apt-get -y install libtiff4-dev libjpeg-dev libjasper-dev sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev sudo apt-get -y install python-dev python-numpy sudo apt-get -y install libtbb-dev libeigen3-dev sudo apt-get -y install libqt4-dev libgtk2.0-dev sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev sudo apt-get -y install x264 v4l-utils ffmpeg sudo apt-get -y install libgtk2.0-dev echo "Downloading OpenCV 2.4.13" if ! [ -f "OpenCV-2.4.13.zip" ]; then wget -O OpenCV-2.4.13.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.13/opencv-2.4.13.zip/download fi echo "Installing OpenCV 2.4.13" if ! [ -d "opencv-2.4.13" ]; then unzip OpenCV-2.4.13.zip fi rm OpenCV-2.4.13.zip cd opencv-2.4.13 rm -rf build mkdir build cd build cmake -D CUDA_ARCH_BIN=3.2 -D CUDA_ARCH_PTX=3.2 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_TIFF=ON -D WITH_QT=ON -D WITH_OPENGL=ON .. make -j sudo make install sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' sudo ldconfig echo "OpenCV 2.4.13 ready to be used"