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?