Created
February 7, 2019 10:31
-
-
Save akmamun/26534f428286831a3d108d498ce70f61 to your computer and use it in GitHub Desktop.
Camera Live Streaming with Flask and Open-CV
This file contains hidden or 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 | |
| camera = cv2.VideoCapture(0) # use 0 for web camera | |
| # for cctv camera'rtsp://username:password@ip_address:554/user=username_password='password'_channel=channel_number_stream=0.sdp' | |
| def camera_stream(): | |
| while True: | |
| # Capture frame-by-frame | |
| success, frame = camera.read() | |
| if not success: | |
| break | |
| else: | |
| ret, buffer = cv2.imencode('.jpg', frame) # or return cv2.imencode('.jpg', frame)[1].tobytes() | |
| return buffer.tobytes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment