Recently began to learn OPENCV to perform computer vision experiments, chose Python as the experimental language, 工欲善其事, its prerequisite. Summarize the installation configuration first.
Now OPENCV visual only supports the python2.7x version, but also relies on the numpy and matplotlib two class libraries.
(I) Pre-preparation
1. Download and install python2.7:https://www.python.org/downloads/Select the latest version 2.7.13
2. Download Pip:https://pypi.python.org/pypi/pip, mainly used to install NumPy and matplotlib two class libraries.
3. Download opencv:http://opencv.org/
(II) installation process
1. Installing Python2.7.13 and OpenCV is simple, similar to installing other software.
2. I unzip the downloaded pip-9.0.1.tar.gz to the folder F:\Python27 the installation Python2.7.13.
3. Open the pip-9.0.1 folder, enter CMD in the Address bar,
In the open script, enter: Python setup.py install, run finished is already installed Pip, simple. This makes it easier to install NumPy and matplotlib below.
4. After the 3rd step completes, the same 3rd step opens the shell script under the PIP folder (you can also use the CD to index to the PIP folder), respectively, to install NumPy and matplotlib in the following two lines of code.
(III) configuration
Suppose you install OPENCV on a f:\opencv,python27 installed in F:\Python27
Copy the file Cv2.pyd below F:\opencv\build\python\2.7\x64 to the F:\Python27\Lib\site-packages folder.
If the python you downloaded is 32-bit, then you should copy the F:\opencv\build\python\2.7\x86 file Cv2.pyd to the F:\Python27\Lib\site-packages folder.
(IV) Testing
Create a new file testopencv.py, and place a picture--gitcat.jpg in the folder where you have this file.
#文件testOpenCV. py
Import= cv2.imread ('gitcat.jpg') #读入图片cv2. Imshow (" opencv-gitcat", img) #显示图片
Cv2.waitkey () cv2.destroyallwindows ()
It's nice to show the picture you want in a window:
Long March the first step, computer vision has a long way to go, I hope this road can go smoothly to graduate, mutual encouragement! ~
PYTHON+OPENCV Configuration under Window environment