This time for everyone to bring PYTHON3+OPENCV configuration tutorial, PYTHON3+OPENCV configuration of the attention to what, the following is the actual case, together to see.
Whether it's windows, Linux, or Raspberry Pi. Configuration Python3 OPENCV environment is a big thing, especially many people with PIP installation, found OpenCV although installed, but installed in the system of the native Python2.
I have experienced many failures before the installation is successful.
This article uses the compiling method to configure the OPENCV, each step has the Ubuntu and the Raspberry Pi separately configures, because two systems extremely similar (can say is basically same), therefore and in the article detailed.
In general, just follow the steps to install the configuration, there is no error. Don't say much nonsense, start acting!
Step1: Preparing for work
1.ubuntu
Pre-installation preparations:
1.1. Update the Ubuntu Apt-get Warehouse
sudo apt-get update && sudo apt-get upgrade
1.2. Install the necessary Python plugins and some environments
sudo apt-get install python3-setuptools python3-dev-y
1.3. Install Pip
sudo easy_install3 pip
1.4. Updates to pip (not necessary)
Pip Install--upgrade pip
1.5. Install the NumPy package
Pip Install NumPy
Some general-purpose packages:
1.6. Installing build-essential
sudo apt-get install build-essential-y
1.7. Other development packages
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev-y
2. Raspberry Pi
Update the system and kernel of the Raspberry Pi
2.1 sudo apt-get update
2.2 sudo apt-get upgrade
2.3 sudo rpi-update
The "No space left on device" error may be reported when updating the kernel because there is not enough storage space, it is best to check the memory usage before updating (use the free command)
Step2: Start Installation OpenCV
ubuntu/Raspberry Pi Universal
1, first, you need to find a suitable place to store OPENCV installation package, I choose the path is ~/DOWNLOAD/OPENCV
2. Go to the installation path and download the installation package
CD ~/download/opencvwget Https://github.com/Itseez/opencv/archive/3.0.0.zip
3, after the download is complete, you need to create the path of the compiled file storage:
Unzip 3.0.0.zip && CD Opencv-3.0.0mkdir build && CD Build
4, the next step, carefully follow the local path to configure, in the build directory to execute the following command:
Cmake-d cmake_build_type=release-d Cmake_install_prefix=/usr/localpython3_executable=/usr/bin/python3python_ Include_dir=/usr/include/python3.4python_library=/usr/lib/x86_64-linux-gnu/libpython3.4m.sopython3_numpy_ Include_dirs=/usr/local/lib/python3.4/dist-packages/numpy/core/include.
Note that there is a line of command, every path to be sure to exist, do not forget the last two points, most of the time the Raspberry Pi and Ubuntu in python_library=/usr/lib/x86_64-linux-gnu/ Libpython3.4m.so This path will be different, in the Raspberry Pi, CD to the/usr/lib/directory, find a directory, there is libpython3.4m.so, (big not one to find), found the path to remember the replacement.
This step, mainly to find files, such as Find python3.4 find libpython3.4m.so find numpy/core/include path, each corresponding replacement can
5, the final execution of the installation command:
Make && sudo make install
Remember that it is executed in the build directory, this step installation time is longer, you can go to see OpenCV's Getting Started Tutorial God horse's
6, if you have completed the previous steps, then congratulate you, start to verify it
Import cv2>>> Print (cv2.version) ... opencv-3.0.0
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
Perfect solution python2.7 cannot use Pip
Python how to read and write txt files line by row