Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FocusGuard

AI-powered study companion for distraction-aware focus sessions

FocusGuard is a Windows desktop application that uses computer vision, real-time monitoring, and local analytics to help students understand and improve their study focus.

It can detect drowsiness, phone usage, and absence from the study area, provide real-time alerts, and track focused vs. distracted time across study sessions.


Python OpenCV YOLO PySide6


Overview

Traditional study timers can tell you how long you studied.

They cannot tell you whether you were actually focused.

FocusGuard explores a different approach by combining:

Study Sessions
      +
Computer Vision
      +
Distraction Detection
      +
Local Analytics

During an active session, FocusGuard monitors webcam input locally and classifies periods as focused or distracted based on signals such as eye activity, phone presence, and user presence.

The application then turns that activity into measurable session statistics and historical insights.


Screenshot

Focus Dashboard

FocusGuard Dashboard


Core Features

Drowsiness Detection

FocusGuard analyzes facial and eye activity using MediaPipe to detect prolonged eye closure and possible drowsiness during an active study session.


Phone Detection

A YOLO11 / Ultralytics object-detection pipeline monitors frames for mobile-phone presence.

When phone usage is detected for the configured condition, FocusGuard can classify that period as distracted and trigger an alert.


Away Detection

FocusGuard monitors whether the user remains present in the study area.

Periods when the user is away can be tracked separately as distracted time.


Real-Time Alerts

Audio alerts help bring the user's attention back when configured distraction conditions are detected.

Possible triggers include:

  • drowsiness
  • phone detection
  • absence from the study area

Focus Sessions

Users can create custom-duration study sessions and monitor progress directly from the desktop application.

During a session FocusGuard tracks:

  • focused time
  • distracted time
  • session progress
  • focus score

Study History

Completed sessions are stored locally and can be reviewed later.

This allows users to compare previous sessions rather than treating every timer session independently.


Analytics Dashboard

FocusGuard turns stored session data into visual insights that help users understand:

  • focus performance
  • study consistency
  • distracted time
  • previous study activity

Configurable Settings

Monitoring behavior and application preferences can be adjusted according to the user's environment and requirements.


System Tray Support

FocusGuard can continue operating from the Windows system tray so the application does not need to occupy the desktop during the entire study session.


How It Works

During an active session:

Webcam
   │
   ▼
Frame Capture
   │
   ├───────────────────────┐
   │                       │
   ▼                       ▼
Face / Eye Analysis    Object Detection
   │                       │
MediaPipe                 YOLO11
   │                       │
   └───────────┬───────────┘
               │
               ▼
        Monitoring Logic
               │
      ┌────────┼────────┐
      │        │        │
      ▼        ▼        ▼
 Drowsiness   Phone    Away
 Detection  Detection Detection
      │        │        │
      └────────┼────────┘
               │
               ▼
       Focus Classification
               │
        ┌──────┴──────┐
        ▼             ▼
     Alerts      Session Stats
                      │
                      ▼
                   SQLite
                      │
                      ▼
             Dashboard / Analytics

Detection Pipeline

Drowsiness

Camera Frame
     ↓
Face Detection
     ↓
Facial / Eye Landmarks
     ↓
Eye Activity Analysis
     ↓
Threshold Evaluation
     ↓
Possible Drowsiness
     ↓
Alert + Distracted Time

Phone Usage

Camera Frame
     ↓
YOLO11 Inference
     ↓
Object Detection
     ↓
Mobile Phone Present?
     ↓
Configured Condition
     ↓
Alert + Distracted Time

Presence Monitoring

Camera Frame
     ↓
User Presence Check
     ↓
User Missing
     ↓
Away Condition
     ↓
Distracted Time

Tech Stack

Technology Purpose
Python Core application
PySide6 Desktop UI
OpenCV Webcam capture and image processing
MediaPipe Face and eye landmark processing
YOLO11 / Ultralytics Phone object detection
PyTorch ML inference
PyQtGraph Analytics visualization
SQLite Local session storage
Pygame Audio alerts
PyInstaller Windows packaging

Application Architecture

FocusGuard separates the desktop interface from continuous monitoring logic so the UI can remain responsive while computer-vision processing runs in the background.

Conceptually:

Desktop UI
    │
    ├── Session Controls
    ├── Dashboard
    ├── History
    ├── Analytics
    └── Settings
            │
            ▼
      Monitor Worker
            │
      ┌─────┴─────┐
      ▼           ▼
 MediaPipe       YOLO
      │           │
      └─────┬─────┘
            ▼
     Focus Analysis
            │
      ┌─────┴─────┐
      ▼           ▼
    Alerts      SQLite
                    │
                    ▼
             Session Analytics

Installation

Recommended — Windows Release

The easiest way to run FocusGuard is through the packaged Windows release.

  1. Open the latest FocusGuard GitHub release.
  2. Download:
FocusGuard-Windows-v1.0.0.zip
  1. Extract the ZIP.
  2. Open the extracted FocusGuard directory.
  3. Run:
FocusGuard.exe
  1. Allow webcam access when required.

Keep FocusGuard.exe inside the extracted application folder because the packaged application depends on bundled _internal files.


Running From Source

Requirements

  • Windows 10/11
  • Python 3.11 recommended
  • Webcam
  • Git

Clone the repository:

git clone https://github.com/Rakshith-028/focusguard.git
cd focusguard

Create a virtual environment:

python -m venv venv

Activate it:

venv\Scripts\activate

Install the required packages:

pip install ultralytics opencv-python mediapipe==0.10.21 pygame PySide6 pyqtgraph

Run FocusGuard:

python app_qt.py

Project Structure

FocusGuard/
│
├── app_qt.py
├── monitor_worker.py
├── detector.py
├── phone_detector.py
├── yolo11n.pt
│
├── focusguard_release.spec
│
├── assets/
│   └── focusguard-dashboard.png
│
└── ...

The internal structure may continue to evolve as the project is developed further.


Privacy

FocusGuard is designed around local processing.

Webcam frames used for monitoring are processed by the desktop application and are not intended to be uploaded to an external server by the core application.

Study-session information is stored locally using SQLite.

This allows the primary focus-monitoring workflow to operate without continuous cloud processing.


Current Version

v1.0.0

The first public Windows release includes:

  • real-time webcam monitoring
  • drowsiness detection
  • phone detection
  • away detection
  • audio distraction alerts
  • configurable focus sessions
  • focused and distracted time tracking
  • focus score
  • study history
  • analytics
  • settings
  • system tray support
  • packaged Windows application

Current Limitations

Computer-vision systems are sensitive to environmental conditions.

Detection performance may vary depending on:

  • camera quality
  • lighting
  • viewing angle
  • face visibility
  • object visibility
  • hardware performance

Phone and drowsiness detections are probabilistic and may occasionally produce false positives or false negatives.

FocusGuard is therefore intended as a productivity assistant, not a safety-critical monitoring system.


Planned Improvements

Possible future improvements include:

  • improved phone-detection accuracy
  • additional distraction categories
  • richer productivity analytics
  • weekly and monthly reports
  • goals and study streaks
  • performance optimization
  • additional customization
  • optional AI-generated study insights

Why I Built FocusGuard

The interesting engineering problem behind FocusGuard was not building another study timer.

It was determining whether a study session could contain information about attention quality, not just duration.

That required combining multiple systems:

  • real-time webcam processing
  • face and eye analysis
  • object detection
  • background monitoring
  • desktop UI development
  • local persistence
  • analytics
  • Windows application packaging

The project became an exploration of how computer vision could be turned into a practical desktop productivity tool rather than existing only as an isolated ML demo.


Disclaimer

FocusGuard is a productivity and study-assistance project.

Its computer-vision detections are probabilistic and can be affected by environmental conditions.

It should not be used as a medical drowsiness detector or as a safety-critical monitoring system.


Author

Rakshith

B.Tech — Artificial Intelligence & Machine Learning

Building AI systems, computer-vision applications, and full-stack products.

GitHub


Support

If you find FocusGuard useful, consider giving the repository a ⭐.

Bug reports, feature requests, and suggestions are welcome through GitHub Issues.


License

A license has not yet been specified for this project.

All rights are reserved unless a license is added.


Turning study time into measurable focus.

About

AI-powered Windows study companion with real-time drowsiness, phone and distraction detection, focus tracking, alerts and analytics.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages