Spaces:
Build error
Build error
Commit
·
19be28f
1
Parent(s):
ee1fe9e
Corregir error de formato string en el componente de cámara
Browse files- streamlit_app.py +11 -11
streamlit_app.py
CHANGED
|
@@ -2529,8 +2529,8 @@ def main():
|
|
| 2529 |
with camera_container:
|
| 2530 |
st.info("Auto-capture enabled. Camera should start automatically.")
|
| 2531 |
|
| 2532 |
-
#
|
| 2533 |
-
|
| 2534 |
<div style="margin-bottom: 20px;">
|
| 2535 |
<video id="webcam" autoplay playsinline width="640" height="480" style="border-radius: 5px; display: none;"></video>
|
| 2536 |
<canvas id="canvas" width="640" height="480" style="display: none;"></canvas>
|
|
@@ -2562,7 +2562,7 @@ def main():
|
|
| 2562 |
let lastBoxes = [];
|
| 2563 |
|
| 2564 |
// Configuración dinámica del FPS (desde Streamlit)
|
| 2565 |
-
const captureDelay = 1000 /
|
| 2566 |
|
| 2567 |
// Iniciar la cámara
|
| 2568 |
async function setupCamera() {
|
|
@@ -2808,10 +2808,10 @@ def main():
|
|
| 2808 |
// Limpiar cuando se desmonte el componente
|
| 2809 |
window.addEventListener('beforeunload', stopCapture);
|
| 2810 |
</script>
|
| 2811 |
-
"""
|
| 2812 |
|
| 2813 |
# Renderizar el componente
|
| 2814 |
-
camera_component = st.components.v1.html(
|
| 2815 |
|
| 2816 |
# Procesar la imagen si está disponible (desde JavaScript)
|
| 2817 |
if camera_component is not None and isinstance(camera_component, dict):
|
|
@@ -2889,13 +2889,13 @@ def main():
|
|
| 2889 |
// 3. Enviar a todos los iframes en la página
|
| 2890 |
try {{
|
| 2891 |
const frames = document.getElementsByTagName('iframe');
|
| 2892 |
-
console.log(`Encontrados ${frames.length} iframes`);
|
| 2893 |
for(let i = 0; i < frames.length; i++) {{
|
| 2894 |
try {{
|
| 2895 |
frames[i].contentWindow.postMessage(message, '*');
|
| 2896 |
-
console.log(`Mensaje enviado a iframe[${i}]`);
|
| 2897 |
}} catch(e) {{
|
| 2898 |
-
console.error(`Error enviando a iframe[${i}]:`, e);
|
| 2899 |
}}
|
| 2900 |
}}
|
| 2901 |
}} catch(e) {{
|
|
@@ -2905,13 +2905,13 @@ def main():
|
|
| 2905 |
// 4. Enviar a todos los iframes en el parent
|
| 2906 |
try {{
|
| 2907 |
const parentFrames = window.parent.document.getElementsByTagName('iframe');
|
| 2908 |
-
console.log(`Encontrados ${parentFrames.length} iframes en parent`);
|
| 2909 |
for(let i = 0; i < parentFrames.length; i++) {{
|
| 2910 |
try {{
|
| 2911 |
parentFrames[i].contentWindow.postMessage(message, '*');
|
| 2912 |
-
console.log(`Mensaje enviado a parent.iframe[${i}]`);
|
| 2913 |
}} catch(e) {{
|
| 2914 |
-
console.error(`Error enviando a parent.iframe[${i}]:`, e);
|
| 2915 |
}}
|
| 2916 |
}}
|
| 2917 |
}} catch(e) {{
|
|
|
|
| 2529 |
with camera_container:
|
| 2530 |
st.info("Auto-capture enabled. Camera should start automatically.")
|
| 2531 |
|
| 2532 |
+
# Construir el HTML del componente de cámara
|
| 2533 |
+
camera_component_html = """
|
| 2534 |
<div style="margin-bottom: 20px;">
|
| 2535 |
<video id="webcam" autoplay playsinline width="640" height="480" style="border-radius: 5px; display: none;"></video>
|
| 2536 |
<canvas id="canvas" width="640" height="480" style="display: none;"></canvas>
|
|
|
|
| 2562 |
let lastBoxes = [];
|
| 2563 |
|
| 2564 |
// Configuración dinámica del FPS (desde Streamlit)
|
| 2565 |
+
const captureDelay = 1000 / {0};
|
| 2566 |
|
| 2567 |
// Iniciar la cámara
|
| 2568 |
async function setupCamera() {
|
|
|
|
| 2808 |
// Limpiar cuando se desmonte el componente
|
| 2809 |
window.addEventListener('beforeunload', stopCapture);
|
| 2810 |
</script>
|
| 2811 |
+
""".format(st.session_state.get('capture_fps', 1.0))
|
| 2812 |
|
| 2813 |
# Renderizar el componente
|
| 2814 |
+
camera_component = st.components.v1.html(camera_component_html, height=520)
|
| 2815 |
|
| 2816 |
# Procesar la imagen si está disponible (desde JavaScript)
|
| 2817 |
if camera_component is not None and isinstance(camera_component, dict):
|
|
|
|
| 2889 |
// 3. Enviar a todos los iframes en la página
|
| 2890 |
try {{
|
| 2891 |
const frames = document.getElementsByTagName('iframe');
|
| 2892 |
+
console.log(`Encontrados ${{frames.length}} iframes`);
|
| 2893 |
for(let i = 0; i < frames.length; i++) {{
|
| 2894 |
try {{
|
| 2895 |
frames[i].contentWindow.postMessage(message, '*');
|
| 2896 |
+
console.log(`Mensaje enviado a iframe[${{i}}]`);
|
| 2897 |
}} catch(e) {{
|
| 2898 |
+
console.error(`Error enviando a iframe[${{i}}]:`, e);
|
| 2899 |
}}
|
| 2900 |
}}
|
| 2901 |
}} catch(e) {{
|
|
|
|
| 2905 |
// 4. Enviar a todos los iframes en el parent
|
| 2906 |
try {{
|
| 2907 |
const parentFrames = window.parent.document.getElementsByTagName('iframe');
|
| 2908 |
+
console.log(`Encontrados ${{parentFrames.length}} iframes en parent`);
|
| 2909 |
for(let i = 0; i < parentFrames.length; i++) {{
|
| 2910 |
try {{
|
| 2911 |
parentFrames[i].contentWindow.postMessage(message, '*');
|
| 2912 |
+
console.log(`Mensaje enviado a parent.iframe[${{i}}]`);
|
| 2913 |
}} catch(e) {{
|
| 2914 |
+
console.error(`Error enviando a parent.iframe[${{i}}]:`, e);
|
| 2915 |
}}
|
| 2916 |
}}
|
| 2917 |
}} catch(e) {{
|