踩坑无数含泪写下教程系列(一)树莓派opencv环境的搭建
Step 1:make sure your OS is current.
sudo apt-get update
sudo apt-get upgrade
Step 2: install dependencies
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
Step 3: install Python 3
sudo apt-get install python3-dev
Step 4: install pip3
sudo apt-get install python3-pip
Step 5: get the latest (3.4.3) OpenCV source code
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.3.zip
wget -O opencv_contrib.zip
https://github.com/opencv/opencv_contrib/archive/3.4.3.zip
unzip opencv.zip
unzip opencv_contrib.zip
Step 6: install Numpy, Scipy
sudo pip3 install numpy scipy
Step 7: compile OpenCV
cd ~/opencv-3.4.3/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
-D BUILD_EXAMPLES=ON …
(Make sure cmake finishes without errors)
Step 8: build OpenCV.
sudo make
Once OpenCV builds successfully, continue the installation:
sudo make install
sudo ldconfig
sudo apt-get update
… then reboot the system - and you should be good to go!
sudo reboot
Step 9: test your OpenCV installation
$ python3
Python 3.5.3 (default, September 5 2018, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import cv2
>>> cv2._version_
‘3.4.3’
>>>