Skip to content

Instantly share code, notes, and snippets.

@akmamun
Created February 7, 2019 10:31
Show Gist options
  • Select an option

  • Save akmamun/26534f428286831a3d108d498ce70f61 to your computer and use it in GitHub Desktop.

Select an option

Save akmamun/26534f428286831a3d108d498ce70f61 to your computer and use it in GitHub Desktop.
Camera Live Streaming with Flask and Open-CV
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