Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
How to get live video stream from the browser (client webcam) with HTML to the server (Flask)?

I want to get live streaming from the client in my web to process it (face recognition and so on) and then display it back to his web.

I already manage to do it with my own camera (host), but I didn't find a solution to do it with the clients webcam.

this is my main code right now:

from flask import Flask, render_template, Response
from camera import VideoCamera

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')

def gen(camera):
    while True:
        frame = camera.get_frame()
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')


@app.route('/video_feed')
def video_feed():
    return Response(gen(VideoCamera()),
                    mimetype='multipart/x-mixed-replace; boundary=frame')


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, threaded=True, use_reloader=False)

The VideoCamera class, capture my webcam (cv2.videocapture(0)) reading teh frames (with the ge_frame() func) process it and then return the image with encoding to jpeg to bytes.

The html part:

<html lang="en">
  <head>
    <title>Face Detector</title>
  </head>
  <body>
    <h1>Face Recognition</h1>
       <img
    src="http://localhost:5000/video_feed"
    alt="loading video stream..."
   />
  </body>
</html>

How can I do it with the clients webcam?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda