Created
October 16, 2020 11:07
Function to generate frames from a camera.
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
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