2019年1月4日

mint 18 下 裝 python + openCV 環境

步驟很多,和參考的網站一併紀錄

# 安裝 openCV
[compiler]
sudo apt-get install build-essential
[required]
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional]
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

sudo apt install python-pip
pip install imutils

#============================================================================================參考: http://carlosdeoliveira.net/en/general/install-opencv-3-3-0-for-linux-mint-18-2ubuntu-for-deep-learning/
#============================================================================================
sudo apt-get install --assume-yes build-essential cmake git
sudo apt-get install --assume-yes pkg-config unzip ffmpeg qtbase5-dev python-dev python3-dev python-numpy python3-numpy
sudo apt-get install --assume-yes libopencv-dev libgtk-3-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
sudo apt-get install --assume-yes libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install --assume-yes libv4l-dev libtbb-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev
sudo apt-get install --assume-yes libvorbis-dev libxvidcore-dev v4l-utils vtk6
sudo apt-get install --assume-yes liblapacke-dev libopenblas-dev libgdal-dev checkinstall

wget -O opencv.zip https://github.com/opencv/opencv/archive/3.3.0.zip
unzip opencv.zip
cd opencv-3.3.0

#開始 compile openCV

mkdir build
cd build/   
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D FORCE_VTK=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D WITH_GDAL=ON -D WITH_XINE=ON -D BUILD_EXAMPLES=ON ..
make -j $(($(nproc) + 1))

4. Install OpenCV 編譯好了安裝
sudo make install
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
sudo apt-get update

#---- testing openCV 測試 python 和 openCV 版本
$ python
>>> import cv2
>>> cv2.__version__
'3.3.0'
#--- see https://matplotlib.org/users/installing.html
python -m pip install -U pip
python -m pip install -U matplotlib
python -m pip install setuptools --user
python -m pip install imutils --user

# 安裝 tracker, see https://stackoverflow.com/questions/42387322/how-to-add-tracker-in-opencv-python-2-7

python -m  pip install opencv-contrib-python --user

# 安裝 matplotlib, see https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_photo/py_non_local_means/py_non_local_means.html
python -m  pip install matplotlib --user

sudo apt install python-tk

沒有留言: