Linux 安装opencv-python opencv4.0.0经验

sudo raspi-config

点击 “Advanced Options” 按钮,后点击 “Expand filesystem”:

sudo reboot

sudo apt-get purge wolfram-engine

sudo apt-get purge libreoffice*

sudo apt-get clean

sudo apt-get autoremove



sudo apt-get update && sudo apt-get upgrade

sudo apt-get install build-essential cmake pkg-config



sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

sudo apt-get install libxvidcore-dev libx264-dev

sudo apt-get install libgtk2.0-dev libgtk-3-dev



sudo apt-get install libatlas-base-dev gfortran

sudo apt-get install python2.7-dev python3-dev



wget https://bootstrap.pypa.io/get-pip.py

sudo python get-pip.py

sudo python3 get-pip.py



sudo pip install virtualenv virtualenvwrapper

sudo rm -rf ~/.cache/pip



export WORKON_HOME=$HOME/.virtualenvs

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

source /usr/local/bin/virtualenvwrapper.sh



echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile

echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile

echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.profile

echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile



source ~/.profile

mkvirtualenv cv -p python2

mkvirtualenv cv -p python3

source ~/.profile

workon cv



pip install numpy

workon cv



wget -O opencv-4.0.0.zip https://github.com/Itseez/opencv/archive/4.0.0.zip

unzip opencv-4.0.0.zip

cd ~/opencv-4.0.0

mkdir build

cd build

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..

make -j2

-j2  此参数指定并行运行任务的数量

sudo make install

执行结束后

cd python_xxx的文件进入

运行

python setup.py build

python setup.py install

然后进入 python

import cv2

cv2.__version__

>>>4.0.0

 

你可能感兴趣的:(Linux 安装opencv-python opencv4.0.0经验)