在 Ubuntu 上安裝 OpenCV
來源連結
開啟終端並編寫以下命令。
1 - 更新和升級你的系統 ubuntu 包:
sudo su
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
2 - 安裝 Dependenices:
sudo apt-get install libopencv-dev
適用於 OpenCV 的 3-Build 工具原始碼:
sudo apt-get install build-essential checkinstall cmake pkg-config
OpenCV 的 4-Image I / O 庫:
sudo apt-get install libtiff5-dev libjpeg-dev libjasper-dev libpng12-dev zlib1g-dev libopenexr-dev libgdal-dev
OpenCV 的 5 視訊 I / O 庫:
sudo apt-get install libavcodec-dev libavformat-dev libmp3lame-dev libswscale-dev libdc1394–22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev v4l-utils libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev x264 yasm
6 並行和線性代數庫:
sudo apt-get install libtbb-dev libeigen3-dev
7-圖形使用者介面庫:
sudo apt-get install libqt4-dev libgtk2.0-dev qt5-default
sudo apt-get install libvtk6-dev
8-Java 安裝:
sudo apt-get install ant default-jdk
9-Python 安裝:
sudo apt-get install python-dev python-tk python-numpy python3-dev python3-tk python3-numpy python-matplotlib
sudo apt-get install python-opencv
sudo apt-get install doxygen
10-從 Github 下載 OPENCV 原始碼:
wget https://github.com/opencv/opencv/archive/3.2.0.zip
11-解壓縮 OPENCV Zip 檔案:
unzip 3.2.0.zip
12 - 刪除 OPENCV Zip 檔案:
rm 3.2.0.zip
13-Build OPENCV:
mv opencv-3.2.0 opencv
cd opencv
mkdir build
cd build
cmake -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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_DOC=ON -D BULD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_EIGEN=ON -D FORCE_VTK=TRUE -D WITH_VTK=ON ..
make -j4
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
14-Finished 檢查你的 OpenCV 版本號:
pkg-config — modversion opencv
pkg-config — cflags opencv