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

464
Visualizações
How to return a video(using opencv-python) from python function to html?

I am trying to return a video from Python to Html app via the eel library. Here are my scripts.

cam_read/web/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Web cam reader</title>
    <style>
    h1{
        color: green;
        text-align: center;
    }
    .webcam{
        margin: 50px;
        font-size: 150px;
        text-align: center;
    }
    button{
        display: block;
        margin: 0 auto;
    }
    </style>
</head>
<body>
    <h1>Web cam reader</h1>
    <div class="webcam"></div>
    <button>Read webcam</button>
    <script type="text/javascript" src="../eel.js"></script>
    <script src="./script.js"></script>
</body>
</html>

cam_read/web/script.js

// Onclick of the button
document.querySelector("button").onclick = function () {
    // Call python's random_python function
    eel.webcam()(function(cam){                 
        // Update the div with a random number returned by python
        document.querySelector(".webcam").innerHTML = cam;
    })
    }   

cam_read/main.py

import cv2

eel.init("web")

# Exposing the webcam function to javascript
@eel.expose 
def webcam():
    vid=cv2.VideoCapture(0)
    while True:
        ret, cam = vid.read()
    '''Code to return cam'''
    
# Start the index.html file
eel.start("/index.html",size=(300,450))

And how I return the webcam to script.js Please help me reach this goal.

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