A real-time screen privacy protection application that uses webcam-based gaze detection to identify when unauthorized individuals are looking at your screen, and responds with configurable privacy measures.
In shared workspaces, co-working environments, and public settings, sensitive on-screen information is vulnerable to shoulder surfing β where nearby individuals can read your screen without your knowledge. This project addresses that by using computer vision to detect when someone other than the primary user is looking at the screen, and automatically triggering privacy countermeasures.
- Real-Time Multi-Face Detection β Detects up to 4 faces simultaneously using MediaPipe FaceMesh with 468 facial landmarks
- Iris-Based Gaze Tracking β Determines gaze direction using iris landmark positions relative to eye outline boundaries
- Primary User Recognition β Identifies the primary user as the largest detected face (closest to screen) and only alerts on secondary faces
- Spotlight Mode β Activates a fullscreen overlay that blacks out the screen except for a spotlight area that follows your mouse cursor
- Screen Dim Mode β Dims the screen using hardware brightness control (with software fallback) to make content unreadable to bystanders
- Live Camera Preview β Manual or auto-triggered 5-second camera preview showing detected faces with bounding boxes and gaze labels
- Desktop Push Notifications β OS-level notifications when a privacy threat is detected
- Alert Cooldown System β Configurable cooldown (default 5 seconds) prevents notification spam
- FastAPI Alert Logging Server β Backend server that logs alert events to a PostgreSQL database via Supabase
- Tkinter GUI Dashboard β Clean desktop interface with master toggle, feature selection, and real-time status display
| Layer | Technology |
|---|---|
| Computer Vision | OpenCV, MediaPipe FaceMesh |
| GUI | Tkinter, Pillow |
| Backend Server | FastAPI, SQLAlchemy |
| Database | PostgreSQL (Supabase) |
| Notifications | Plyer |
| Brightness Control | screen-brightness-control |
| Language | Python 3.11+ |
ScreenPrivacyProject/
βββ client_app/
β βββ screen_privacy.py # Main desktop application (gaze detection + GUI)
βββ server/
β βββ main.py # FastAPI server for alert logging
β βββ requirements.txt # Server dependencies
β βββ .env.example # Environment variable template
βββ .gitignore
βββ README.md
- Python 3.11 or higher
- A webcam
- PostgreSQL database (or Supabase account for hosted DB)
cd client_app
pip install opencv-python mediapipe numpy pillow pyautogui plyer screen-brightness-controlcd server
pip install -r requirements.txtCreate a .env file in the server/ directory:
DATABASE_URL=postgresql://user:password@host:5432/dbname
Create an alerts table in your PostgreSQL database:
CREATE TABLE alerts (
id SERIAL PRIMARY KEY,
event TEXT NOT NULL,
timestamp TEXT NOT NULL
);cd server
uvicorn main:app --reloadThe server runs at http://127.0.0.1:8000. Visit http://127.0.0.1:8000/docs for the interactive API documentation.
cd client_app
python screen_privacy.py- Enable the main toggle to start webcam monitoring
- Select a privacy feature: Spotlight or Screen Dim
- Optionally enable Video Preview (manual or auto) and Push Notifications
- Position yourself as the primary user (closest to the webcam)
- When another person looks at your screen, the selected privacy measure activates
- Press ESC to exit any active privacy overlay
Screenshots will be added here.
[Webcam] β [MediaPipe FaceMesh] β [Gaze Analysis] β [Alert Decision]
β
ββββββββββββββββββββββββββββββ€
βΌ βΌ
[Privacy Response] [FastAPI Server]
- Spotlight overlay - POST /log-alert
- Screen dimming - PostgreSQL storage
- Push notification
- Camera preview
I independently designed and developed this entire application, including:
- Implementing iris-based gaze detection using MediaPipe FaceMesh landmarks
- Building the multi-face tracking system that distinguishes the primary user from bystanders
- Developing the spotlight and screen dimming privacy overlays with smooth cursor tracking
- Creating the Tkinter GUI with dynamic feature toggling
- Setting up the FastAPI backend with SQLAlchemy for alert event logging
- Integrating hardware brightness control with software fallback
This project is for educational and demonstration purposes.