diff --git a/realtime_video.py b/realtime_video.py new file mode 100644 index 0000000000000000000000000000000000000000..5a79fe64445d9277d4ad7ea0d6c6b81a8bc7c9c6 --- /dev/null +++ b/realtime_video.py @@ -0,0 +1,37 @@ +import cv2 +import random + + +def main(): + cap = cv2.VideoCapture(0) + + if ~cap.isOpened(): + print("Warning: cannot reach camera") + + while cap.isOpened(): + ret, frame = cap.read() + + if not ret: + print("Warning: cannot read camera input") + break + + frame = cv2.flip(frame, 1) + + frameRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) + + cv2.imshow('Frame', frame) + if cv2.waitKey(1) & 0xFF == ord('q'): + print("Quit camera") + break + + cap.release() + cv2.destroyAllWindows() + print("Program closed") + +if __name__ == '__main__': + main() + + + + +