Spaces:
Build error
Build error
Commit
·
17acc92
1
Parent(s):
a9e5470
Reescribir completamente el componente de cámara para evitar problemas de formateo
Browse files- streamlit_app.py +16 -5
streamlit_app.py
CHANGED
|
@@ -2529,9 +2529,11 @@ def main():
|
|
| 2529 |
with camera_container:
|
| 2530 |
st.info("Auto-capture enabled. Camera should start automatically.")
|
| 2531 |
|
| 2532 |
-
# Construir el
|
| 2533 |
-
fps_value = st.session_state.get('capture_fps', 1.0)
|
| 2534 |
-
|
|
|
|
|
|
|
| 2535 |
<div style="margin-bottom: 20px;">
|
| 2536 |
<video id="webcam" autoplay playsinline width="640" height="480" style="border-radius: 5px; display: none;"></video>
|
| 2537 |
<canvas id="canvas" width="640" height="480" style="display: none;"></canvas>
|
|
@@ -2563,7 +2565,13 @@ def main():
|
|
| 2563 |
let lastBoxes = [];
|
| 2564 |
|
| 2565 |
// Configuración dinámica del FPS (desde Streamlit)
|
| 2566 |
-
const captureDelay = 1000 / """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2567 |
|
| 2568 |
// Iniciar la cámara
|
| 2569 |
async function setupCamera() {
|
|
@@ -2809,7 +2817,10 @@ def main():
|
|
| 2809 |
// Limpiar cuando se desmonte el componente
|
| 2810 |
window.addEventListener('beforeunload', stopCapture);
|
| 2811 |
</script>
|
| 2812 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 2813 |
|
| 2814 |
# Renderizar el componente
|
| 2815 |
camera_component = st.components.v1.html(camera_component_html, height=520)
|
|
|
|
| 2529 |
with camera_container:
|
| 2530 |
st.info("Auto-capture enabled. Camera should start automatically.")
|
| 2531 |
|
| 2532 |
+
# Construir el componente de cámara con JavaScript sin formateo complejo
|
| 2533 |
+
fps_value = str(st.session_state.get('capture_fps', 1.0))
|
| 2534 |
+
|
| 2535 |
+
# Primera parte del HTML (antes del valor de FPS)
|
| 2536 |
+
camera_html_part1 = """
|
| 2537 |
<div style="margin-bottom: 20px;">
|
| 2538 |
<video id="webcam" autoplay playsinline width="640" height="480" style="border-radius: 5px; display: none;"></video>
|
| 2539 |
<canvas id="canvas" width="640" height="480" style="display: none;"></canvas>
|
|
|
|
| 2565 |
let lastBoxes = [];
|
| 2566 |
|
| 2567 |
// Configuración dinámica del FPS (desde Streamlit)
|
| 2568 |
+
const captureDelay = 1000 / """
|
| 2569 |
+
|
| 2570 |
+
# Valor de FPS (como string)
|
| 2571 |
+
camera_html_part2 = fps_value
|
| 2572 |
+
|
| 2573 |
+
# Resto del HTML (después del valor de FPS)
|
| 2574 |
+
camera_html_part3 = """;
|
| 2575 |
|
| 2576 |
// Iniciar la cámara
|
| 2577 |
async function setupCamera() {
|
|
|
|
| 2817 |
// Limpiar cuando se desmonte el componente
|
| 2818 |
window.addEventListener('beforeunload', stopCapture);
|
| 2819 |
</script>
|
| 2820 |
+
"""
|
| 2821 |
+
|
| 2822 |
+
# Unir todas las partes para formar el HTML completo
|
| 2823 |
+
camera_component_html = camera_html_part1 + camera_html_part2 + camera_html_part3
|
| 2824 |
|
| 2825 |
# Renderizar el componente
|
| 2826 |
camera_component = st.components.v1.html(camera_component_html, height=520)
|