Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Screen Privacy Protection System

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.

Problem Statement

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.

Features

  • 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

Tech Stack

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+

Project Structure

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

Installation

Prerequisites

  • Python 3.11 or higher
  • A webcam
  • PostgreSQL database (or Supabase account for hosted DB)

Client Application Setup

cd client_app
pip install opencv-python mediapipe numpy pillow pyautogui plyer screen-brightness-control

Server Setup

cd server
pip install -r requirements.txt

Create a .env file in the server/ directory:

DATABASE_URL=postgresql://user:password@host:5432/dbname

Database Setup

Create an alerts table in your PostgreSQL database:

CREATE TABLE alerts (
    id SERIAL PRIMARY KEY,
    event TEXT NOT NULL,
    timestamp TEXT NOT NULL
);

How to Run

1. Start the Alert Logging Server

cd server
uvicorn main:app --reload

The server runs at http://127.0.0.1:8000. Visit http://127.0.0.1:8000/docs for the interactive API documentation.

2. Launch the Client Application

cd client_app
python screen_privacy.py

3. Using the Application

  1. Enable the main toggle to start webcam monitoring
  2. Select a privacy feature: Spotlight or Screen Dim
  3. Optionally enable Video Preview (manual or auto) and Push Notifications
  4. Position yourself as the primary user (closest to the webcam)
  5. When another person looks at your screen, the selected privacy measure activates
  6. Press ESC to exit any active privacy overlay

Screenshots

Screenshots will be added here.

Architecture

[Webcam] β†’ [MediaPipe FaceMesh] β†’ [Gaze Analysis] β†’ [Alert Decision]
                                                           β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                              β–Ό                            β–Ό
                     [Privacy Response]           [FastAPI Server]
                     - Spotlight overlay          - POST /log-alert
                     - Screen dimming             - PostgreSQL storage
                     - Push notification
                     - Camera preview

My Role

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

License

This project is for educational and demonstration purposes.

About

πŸ”’ Real-time screen privacy protection using webcam-based gaze detection β€” blurs screen when unauthorized viewing is detected. Python + OpenCV.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages