Python beautician OpenCV Frame, three boutique cases, add up to no more than 40 lines of code?

Source: Internet
Author: User

OpenCV Brief Introduction:

A library of open source functions for image processing, analysis, and machine vision. Able to run on Windows, Linux, Mac OSX systems. All of the code in the Python library has been optimized, so it's highly efficient, and it's very focused on designing an open source library for real-time systems.

To import a module method:

Import Cv2

Case one: Know OpenCV with actual combat

# 1 Loading a picture

# image = Cv2.imread (' d:windows 7 documentsdesktoppp.jpg ')

# # 2 Create a window

# Cv2.namedwindow (' image ')

# # 3 Set a function purpose: Click on real-time mouse state

# def draw (Event,x,y,flags,param):

# # 3.1 Judging mouse events

# if event = = Cv2. Event_lbuttondown:

# print (' Mouse down ')

# elif Event = = Cv2. Event_mousemove:

# Print (' slide ' with mouse)

# elif Event = = Cv2. Event_lbuttonup:

# print (' Lift ' with mouse)

# # 4 Listen for mouse events callback window and callback function

# cv2.setmousecallback (' image ', draw)

# # 5 Display window

# cv2.imshow (' image ', image)

# # 6 Window waiting

# cv2.waitkey (0)

# # 7 destroying Windows

# cv2.destroyallwindows ()

Case two blurring of picture

# 1 Loading a picture

# image = Cv2.imread (' d:windows 7 documentsdesktoppp.jpg ')

# # 2 picture blur the first parameter we want to blur the object (picture) the greater the degree of ambiguity in the second parameter, the greater the blur.

# IMAGE_DST = Cv2.blur (image, (15,15))

# # 3 Create a window

# Cv2.namedwindow (' image ')

# # 4 Display window

# cv2.imshow (' image ', IMAGE_DST)

# # 5 Window waiting

# cv2.waitkey (0)

# # 6 destroying Windows

# cv2.destroyallwindows ()

Case Three beauty 美图秀秀 function

# 1 Loading a picture

Image = Cv2.imread (' d:windows 7 documentsdesktoppp.jpg ')

# 2 Pictures Whitening value The bigger the beauty, the smaller the beauty is, the less

Value = 20

IMAGE_DST = Cv2.bilateralfilter (Image,value,value * 2,value/2)

#7生成图片

# cv2.imwrite (' D:windows 7 documentsdesktoppp_new.jpg ', IMAGE_DST)

# 3 Create a window

Cv2.namedwindow (' image ')

# 4 Display window

Cv2.imshow (' image ', IMAGE_DST)

# 5 Window Waiting

Cv2.waitkey (0)

# 6 destroying Windows

Cv2.destroyallwindows ()

To the end of these three Python tutorials

Python beautician OpenCV Frame, three boutique cases, add up to no more than 40 lines of code?

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.