ubuntu下安裝opencv3.3(詳細教程)
阿新 • • 發佈:2019-01-27
opencv建議安裝3.3及以後版本吧,對以後想要深度學習,神經網路都很方便
要注意的一點是一定要先安裝CUDA後安裝opencv,否則不能使用GPU,很麻煩
先安裝一下依賴吧,很多,還是全一點好,要比到時候報錯好很多
sudo apt-get install --assume-yes libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip sudo apt-get install build-essential cmake git sudo apt-get install ffmpeg libopencv-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
依賴安裝好後就可以去opencv官網,下載opencv3.3了
https://opencv.org/opencv-3-3.html,選擇最後的The source code for all platforms can be downloaded from GitHub: zip
下載好後就可以進行安裝了
cd opencv-3.3.0 mkdir my_build_dir_gpu cd my_build_dir_gpu cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D WITH_CUBLAS=1 \.. make -j4 sudo make install
echo '/usr/local/lib' | sudo tee -a /etc/ld.so.conf.d/opencv.conf sudo ldconfig printf '# OpenCV\nPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig\nexport PKG_CONFIG_PATH\n' >> ~/.bashrc source ~/.bashrc