Mission objectives :

use python Call camera , The image obtained by the camera is processed (cv2).

Code implementation results :

Import image processing package :
import cv2
Camera on :
# Get camera cap = cv2.VideoCapture(0,cv2.CAP_DSHOW) # Turn on the camera cap.open(0)
Get image , And deal with it :
while cap.isOpened(): # Get picture flag, frame = cap.read()
###################### Picture processing 1########################## # Grayscale image frame =
cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.medianBlur(frame, 5)
img_blur = cv2.GaussianBlur(frame, ksize=(21, 21), sigmaX=0, sigmaY=0) frame =
cv2.divide(frame, img_blur, scale=255) # Screen display cv2.imshow('mytest', frame)
# Set exit button key_pressed = cv2.waitKey(100)
print(' Stand alone window , Input key , Computer keys are ',key_pressed,' Press esc Key end ') if key_pressed == 27: break
Turn off the camera :
# Turn off the camera cap.release() # Close image window cv2.destroyAllWindows()
Complete code :
import cv2 # Get camera cap = cv2.VideoCapture(0,cv2.CAP_DSHOW) # Turn on the camera cap.open(0)
while cap.isOpened(): # Get picture flag, frame = cap.read()
###################### Picture processing 1########################## # Grayscale image frame =
cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.medianBlur(frame, 5)
img_blur = cv2.GaussianBlur(frame, ksize=(21, 21), sigmaX=0, sigmaY=0) frame =
cv2.divide(frame, img_blur, scale=255) # Screen display cv2.imshow('mytest', frame)
# Set exit button key_pressed = cv2.waitKey(100)
print(' Stand alone window , Input key , Computer keys are ',key_pressed,' Press esc Key end ') if key_pressed == 27: break
# Turn off the camera cap.release() # Close image window cv2.destroyAllWindows()

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq