Last active
March 13, 2018 13:38
-
-
Save paulaksm/2fc6e7d1a6181e150590b16c11679db3 to your computer and use it in GitHub Desktop.
Simple camera test for Python3 and OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
''' | |
CAMERA TEST | |
''' | |
cam = cv2.VideoCapture(0) | |
ret, frame = cam.read() | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
cv2.imwrite('gray.png', gray) | |
cv2.namedWindow('Test display', cv2.WINDOW_NORMAL) | |
cv2.imshow('image', gray) | |
cv2.waitKey(0) # waits for Esc key to close window and end program | |
cv2.destroyAllWindows() | |
# ''' | |
# VIDEO TEST | |
# ''' | |
# import numpy as np | |
# import cv2 | |
# cap = cv2.VideoCapture(0) | |
# while(True): | |
# ret, frame = cap.read() | |
# gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
# cv2.imshow('frame',gray) | |
# if cv2.waitKey(1) & 0xFF == ord('q'): | |
# break | |
# cap.release() | |
# cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment