This webapp warns users if they are sitting too close to their screen. Using the device's camera and AI-based face detection powered by the Human.js library, the app measures the user's proximity to the screen and provides an audible and visual warning if they are too close.
- Detects the user's face and calculates the distance from the screen.
- Displays a visual warning and plays an audio alert when the user is too close.
- User-friendly interface with start and stop controls for the camera.
- A modern web browser with WebRTC support (e.g., Chrome, Firefox, Edge).
- Access to the device's camera.
- Open the app in your browser.
- Click Enable Camera to start face detection.
- If you move too close to the screen, a warning will:
- Display a red message: "You are too close to the screen!"
- Play an audio alert.
- Click Disable Camera to stop detection and turn off the camera.
- Face Detection: The app uses Human.js to detect the user's face and measure its dimensions.
- Distance Calculation: Based on the width of the detected face in pixels, the app calculates an approximate distance.
- Warning Threshold: If the calculated distance is below a predefined threshold, the app triggers a warning.
To modify the distance sensitivity, update the following line in app.js
:
if (distance < 0.0035) {
warnUser();
}
Replace 0.0035
with your desired threshold value.
git clone https://github.com/SammriddhGupta/Screen-Sentry.git
The app requires a server to serve the files. You can use a lightweight server like http-server
:
Note: using -g
installs it globally in your system
npm install -g http-server
Navigate to the project folder and start the server:
http-server
The app will be available at http://localhost:8080
by default.
- Human.js: AI-powered face detection library (GitHub).
- Audio Credit: Sound Effect by Otto from Pixabay.
- Favicon Credit: Spyware icons created by Freepik - Flaticon.