Spaces:
Build error
Build error
| import streamlit as st | |
| from streamlit_webrtc import webrtc_streamer | |
| import av | |
| import cv2 | |
| import numpy as np | |
| def video_frame_callback(frame): | |
| img = frame.to_ndarray(format="bgr24") | |
| # Simulated detection: red rectangle in the center | |
| h, w, _ = img.shape | |
| cv2.rectangle(img, (w//4, h//4), (w*3//4, h*3//4), (0, 0, 255), 2) | |
| return av.VideoFrame.from_ndarray(img, format="bgr24") | |
| st.title("NeuroNudge – Screen Distance Detector") | |
| webrtc_streamer( | |
| key="face-detect", | |
| video_frame_callback=video_frame_callback, | |
| rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}, | |
| media_stream_constraints={"video": True, "audio": False}, | |
| ) | |