Python version OpenCV installation configuration and simple example

Source: Internet
Author: User

# 2018-06-03 #

1. python Download: https://www.python.org/downloads/

Select the appropriate version of Python for the corresponding platform to install.

2. python version OpenCV installation:

If the Python environment is already configured globally on your computer, you can install it directly with the PIP Package Management tool and open cmd Direct input:

PIP3 Install Opencv-python

If the Python environment is not configured or Python is isolated, you can downgrade the PIP tool to the appropriate folder, such as:

3. A simple example, through Python's 3rd party package NumPy to build a diagram and display:

The code is:

#-*-coding:utf-8-*-ImportCv2ImportNumPy as NPPrint(Cv2.__version__)#Build a pictureimg = Np.zeros ([3], dtype=np.uint8)#iterate through each pixel and assign a value. forIinchRange (512):     forJinchRange (512): Img[i, J,:]= [i%, j%, (i + j)% 256]#Show PicturesCv2.namedwindow ('Custom Image', Cv2. Window_normal) Cv2.imshow ('Custom Image', IMG) cv2.waitkey (0) cv2.destroyallwindows ()

Results

4. Summary

Using Python to write OPENCV-related image processing algorithms is more convenient, eliminating the tedious configuration of the C + + process, the code is clearer, can be faster to achieve their own ideas. You can first use Python to realize their own ideas, see if it is feasible, and then use C + + for field product development!

Python version OpenCV installation configuration and simple example

Related Article

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.