Inspiration
In an era of relentless notifications, infinite scrolling feeds, and multitasking overload, staying focused is harder than ever. Most website blockers and productivity apps share the same fundamental flaws:
- They are trivial to bypass: A simple shortcut, incognito window, or process kill disables them.
- They lack physical awareness: They don't know whether you are actively sitting at your desk, daydreaming, or if someone else has sat down at your workstation.
- They rely on crude domain blocklists: They cannot differentiate between reading documentation on Reddit or watching gaming clips, nor do they understand visual desktop context. We built FocusGuard to reinvent distraction management as an intelligent, biometric-anchored guardian for your workstation. FocusGuard pairs low-level OS telemetry with on-device computer vision and multimodal AI—ensuring that you only unlock your deep-work environment with your own face, and gently steering you back on track whenever you drift away.
What it does
FocusGuard is a high-performance, two-tier productivity and biometric workstation security suite that:
- Biometric Face ID & Lock Screen Gate: Gates monitoring and desktop enforcement behind local facial recognition. On launch, a custom Win32 dark-mode lock screen requires biometric verification before granting focus privileges.
- Presence Auto-Lock: Periodically probes the camera for user presence in under (150\text{ ms}). If you step away from your desk for over 60 seconds (or lock Windows), FocusGuard instantly engages security lock mode and pauses tracking.
- Anti-Spoofing Liveness Defense: Analyzes multi-frame landmark micro-movements and Eye Aspect Ratio (EAR) fluctuations to reject static photos, phone displays, and prerecorded video replays.
- Real-Time Multi-Browser URL Sniffing: Uses Windows UI Automation (
IUIAutomation) to inspect the active tabs of Microsoft Edge, Google Chrome, Brave, and Mozilla Firefox in real time without requiring browser extensions (though a companion extension is also available). - 3-Tier Distraction Escalation Engine:
- ⚠️ 2s Warning: Gentle notification nudge.
- 🚨 7s Strong Alert: Persistent visual toast and audio cue.
- 🛑 10s Intervention: Automatically minimizes distracting windows and locks out unproductive workflows.
- Multimodal Visual AI (Qwen 2.5-VL / Gemma 3): When URLs or window titles are ambiguous, FocusGuard captures the screen via high-speed DirectX duplication (
dxcam) and uses local visual LLMs to determine whether your activity aligns with your active goals. - Zero-Cloud, Privacy-First Architecture: 100% on-device. No camera feeds or screenshots ever leave the machine. Biometric templates are stored as 128-dimensional mathematical vectors encrypted with Windows DPAPI.
How we built it
FocusGuard was engineered with a hybrid, two-tier architecture prioritizing native performance and modern AI capabilities:
1. High-Performance C++17 Daemon (focusguard_monitor)
- Compiled with CMake and Ninja using modern C++17.
- Directly hooks into Win32 APIs (
PROCESS_QUERY_LIMITED_INFORMATION,QueryFullProcessImageNameA) to capture active process state in microseconds. - Utilizes COM-based Microsoft UI Automation to extract real-time URL bar strings across top Chromium and Gecko browsers.
- Manages the state machine: $$\text{LOCKED} \xrightarrow{\text{Face ID / PIN}} \text{AUTHENTICATING} \xrightarrow{\text{Success}} \text{UNLOCKED} \xrightarrow{\text{Absence } > 60\text{s}} \text{LOCKED}$$ ### 2. Python Vision & Biometric Bridge
- Face Detection: Powered by OpenCV YuNet (
face_detection_yunet_2023mar.onnx), performing ultra-fast face bounding and 5-point facial landmark extraction in < 10 ms on CPU. - Feature Extraction: Powered by OpenCV SFace (
face_recognition_sface_2021dec.onnx), mapping facial geometry into a normalized 128-dimensional hypersphere (u ∈ ℝ¹²⁸). - Matching Metric: We compute Cosine Similarity between enrolled template (u) and live sample (v):
$$ S_C(\mathbf{u}, \mathbf{v}) = \frac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{u}|_2 |\mathbf{v}|_2} \ge 0.363 $$
Matches are authenticated when Cosine Similarity ≥ 0.363 (SFace verification threshold).
- Liveness & Anti-Spoofing: Calculates multi-frame landmark dispersion and Eye Aspect Ratio (EAR):
$$ \text{EAR} = \frac{|p_2 - p_6|_2 + |p_3 - p_5|_2}{2|p_1 - p_4|_2} $$
Matches are authenticated when Cosine Similarity ≥ 0.363 (SFace verification threshold).
- Liveness & Anti-Spoofing: Calculates multi-frame landmark dispersion and Eye Aspect Ratio (EAR):
$$ \text{EAR} = \frac{|p_2 - p_6|_2 + |p_3 - p_5|_2}{2|p_1 - p_4|_2} $$
Ensures natural blinking and 3D micro-movement before confirming identity.
- Hardware-Backed Encryption: Biometric arrays are encrypted via Windows Data Protection API (
CryptProtectData), tying the template directly to the active Windows user account. - Visual Understanding: Local multimodal inference with Qwen 2.5-VL (3B) and Gemma 3 via Ollama for semantic screen classification. ### 3. Glassmorphic Web Dashboard & Policy Studio
- Real-time distraction radar with animated escalation states.
- Policy customization (Whitelist/Blacklist, strict exam mode, dev mode).
- Real-time activity simulator and productivity analytics.
Challenges we ran into
- Sub-Second Biometric Verification without GPU Hogging: Running neural models on consumer laptops while users are actively working requires near-zero overhead. We transitioned from bulky deep learning frameworks to lightweight ONNX models (YuNet + SFace) executed natively via OpenCV's DNN backend, bringing face detection down to sub-10ms on CPU.
- Preventing Spoof Attacks with Standard Webcams: Without specialized TrueDepth or IR sensors, software-only anti-spoofing is notoriously difficult. We implemented temporal micro-variance tracking of facial landmarks and EAR calculations across 20-frame buffers to cleanly reject static paper and smartphone screen presentations.
- Low-Overhead Win32 UI Automation: Calling UI Automation on the primary monitoring thread initially created subtle UI micro-stutters in third-party browsers. We resolved this by decoupling process polling, UI Automation tree walking, and policy actions across isolated worker threads with thread-safe atomic flags.
- Zero-Trust Biometric Security: Storing photos or raw video on disk is unacceptable for privacy. We engineered a strict discard pipeline: frames exist only in transient RAM, and only normalized floating-point embeddings are encrypted using OS-level DPAPI keys.
Accomplishments that we're proud of
- Lightning Fast: Sub-10ms face detection and sub-150ms presence verification running purely on consumer CPUs.
- Ironclad Privacy: Absolutely zero telemetry, zero cloud calls, and zero retained camera images.
- Robust Hybrid Engineering: A seamless bridge between a low-level C++17 Win32 monitoring daemon and an intelligent Python AI engine via a local JSON-RPC/HTTP micro-API.
- Smooth User Experience: A beautiful, non-intrusive distraction escalation workflow that balances user empathy (warnings) with resolute enforcement (auto-minimization).
What we learned
- Mastered low-level Windows UI Automation and process introspection using Win32 C++.
- Gained deep practical knowledge in biometric embedding spaces, cosine similarity thresholds, and computer vision anti-spoofing techniques.
- Explored local small multimodal models (Qwen 2.5-VL / Gemma) for real-time semantic desktop understanding.
- Learned how to implement hardware-bound OS encryption with Windows DPAPI to safely store sensitive mathematical vectors.
What's next for FocusGuard
- Cross-Platform Parity: Porting the background daemon to macOS (via
CoreGraphics& Quartz) and Linux (via Wayland/X11). - NPU Acceleration: Leveraging Windows DirectML and Intel/Qualcomm NPU runtimes for zero-CPU background inference.
- Calendar & Deep-Work Goal Integration: Automatic session scheduling synced with Google Calendar and Notion tasks.
- Posture & Ergonomics Alerting: Extending the YuNet facial landmark pipeline to monitor neck strain and screen distance during prolonged focus sprints.
Built With
- artificial-intelligence
- biometrics
- c++
- chrome
- cmake
- computer-vision
- cryptography
- css3
- cybersecurity
- directx
- dpapi
- gemma
- html5
- javascript
- liveness-detection
- machine-learning
- ollama
- onnx
- opencv
- python
- qwen2.5-vl
- rest-api
- ui-automation
- win32-api
Log in or sign up for Devpost to join the conversation.