1. Build the OPENCV environment under Python
The most recent version of Python is 2.7.3, so this is a python-based learning OpenCV, and just add some other packages to it.
For example, the first program requires a package, such as
NumPy: The module of scientific calculation, contains the rich function, the configuration OpenCV also need this module
cv2:opencv2.x version, here choose opencv2.4.7
Install the NumPy module only need to use PIP or Easy_install, here is also recommended with PIP, a command line:
pip install numpy
Wait to complete, test whether to install a successful method, with import xxx, no error is the success
Originally thought that only need a simple command, the result installs the CV2 module cannot use the PIP, the net said can only use the download library inside the cv2.pyd file to copy over the form:
I directly unzip to find the inside support python file cv2.pyd, copy to C:\Python27\Lib\site-packages.
Test import Cv2, no error, success.
2. Display a picture
A word of discord, directly paste the code up:
1 #-*-coding:utf-8-*-2 3 ImportNumPy as NP4 ImportCv25 6 #show a picture7img = Cv2.imread ('koala.jpg', 0)8Cv2.imshow ('Image', IMG)9 cv2.waitkey (0)TenCv2.destroyallwindows ()
show a picture
Show the effect:
Complete.
Python_opencv_ show a picture