Python_opencv_ show a picture

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.