-
-
Save parzibyte/3bb8348ce14e7ab19c2e7f43b92e39bd to your computer and use it in GitHub Desktop.
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
# Una función generadora para stremear la cámara | |
# https://flask.palletsprojects.com/en/1.1.x/patterns/streaming/ | |
def generador_frames(): | |
while True: | |
ok, imagen = obtener_frame_camara() | |
if not ok: | |
break | |
else: | |
# Regresar la imagen en modo de respuesta HTTP | |
yield b"--frame\r\nContent-Type: image/jpeg\r\n\r\n" + imagen + b"\r\n" | |
# Más tarde... | |
# Cuando visiten la ruta | |
@app.route("/streaming_camara") | |
def streaming_camara(): | |
return Response(generador_frames(), mimetype='multipart/x-mixed-replace; boundary=frame') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment