Skip to content

Instantly share code, notes, and snippets.

@NakulLakhotia
Created October 16, 2020 11:07
Function to generate frames from a camera.
def gen_frames():
while True:
success, frame = camera.read() # read the camera frame
if not success:
break
else:
ret, buffer = cv2.imencode('.jpg', frame)
frame = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') # concat frame one by one and show result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment