Skip to content

Instantly share code, notes, and snippets.

@italojs
Created June 29, 2018 02:31
Show Gist options
  • Save italojs/45891f24615f914f6e809abd3da3f40c to your computer and use it in GitHub Desktop.
Save italojs/45891f24615f914f6e809abd3da3f40c to your computer and use it in GitHub Desktop.
import cv2
# if (you have only 1 webcam){ set device = 0} else{ chose your favorite webcam setting device = 1, 2 ,3 ... }
cap = cv2.VideoCapture(0)
while True:
# Getting our image by webcam and converting it into a gray image scale
_, image = cap.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# show the gray image
cv2.imshow("Output", image)
#key to give up the app.
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment