Skip to content

mannasdev/lookatscreen

Repository files navigation

LookAtScreen

A focus-enforcement utility that uses webcam gaze detection to play a meme video when you look away from your screen. Stay focused or face the consequences.

Features

  • Real-time eye gaze tracking via webcam
  • Configurable delay threshold before alarm triggers
  • Automatic video playback with audio when you look away
  • Immediate stop when you look back at the screen
  • Live visual feedback with face and eye tracking overlays

Requirements

  • Python 3.7+
  • macOS (uses QuickTime Player for video playback)
  • Webcam

Installation

pip install -r requirements.txt

Usage

# Basic usage
python main.py --video path/to/meme.mp4

# Custom threshold (wait 2 seconds before alarm)
python main.py --video meme.mp4 --threshold 2.0

# Stricter gaze detection
python main.py --video meme.mp4 --gaze-tolerance 0.10

# Set volume
python main.py --video meme.mp4 --volume 80

Controls

  • Press q to quit

Options

Argument Default Description
--video required Path to video file to play as alarm
--threshold 0.5 Seconds of looking away before alarm triggers
--gaze-tolerance 0.15 Gaze tolerance from center (0.0-1.0, smaller = stricter)
--volume 100 Video volume level (0-100)

How It Works

  1. Captures frames from webcam using OpenCV
  2. Detects facial landmarks using MediaPipe Face Mesh
  3. Calculates iris position to determine if you're looking at the screen
  4. Starts a timer when you look away
  5. Plays the alarm video when the timer exceeds the threshold
  6. Stops the video immediately when you look back

Project Structure

├── main.py              # Entry point and main loop
├── gaze_detector.py     # Eye tracking using MediaPipe
├── alarm_controller.py  # Video playback control
├── config.py            # Configuration constants
├── requirements.txt     # Python dependencies
└── face_landmarker.task # MediaPipe pre-trained model

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages