Skip to main content

๐Ÿง  AI Real-Time Emotion, Health (rPPG) & Focus Tracker

An all-in-one, 100% local computer vision workstation companion: Fusing contactless rPPG pulse, AffectNet emotion, iris gaze attention, and local LLM coaching into a lightweight Windows tray app.

Python 3.10+ PyPI License: MIT ONNX DirectML Privacy: 100% Local

A lightweight, research-grade, multimodal computer vision and affective computing system that runs 100% locally using a single standard RGB webcam.

It real-time tracks contactless physiological vitals (rPPG heart rate), AffectNet deep learning emotions, 3D head pose & iris eye-gaze focus, and ISO PERCLOS fatigue, complete with local SQLite logging, a Windows system tray daemon, and an Ollama-powered Local AI Health Coach.


๐ŸŒŸ Key Features

  • โค๏ธ Contactless Physiology (rPPG & HRV): Measures blood volume pulse (BVP) via facial micro-color shifts (POS/CHROM algorithms), Butterworth bandpass filtering, and FFT power spectrum to calculate real-time Heart Rate (BPM) and pulse waveforms without wearable sensors.
  • ๐Ÿ˜Š Deep Learning Emotion Recognition: Powered by an AffectNet-pretrained HSEmotion ONNX model with DirectML GPU acceleration, temporal exponential moving average (EMA) smoothing, and desk neutral-prior calibration to eliminate resting-face false positives.
  • ๐Ÿ‘€ 3D Iris Eye-Gaze & Attention Fusion: Uses MediaPipe 468 3D mesh + refined iris points (468โ€“477) fused with SolvePnP 3D head pose (Pitch/Yaw/Roll) for robust screen attention & focus scoring ($0โ€“100%$).
  • ๐Ÿ˜ด ISO PERCLOS Drowsiness & Fatigue Detection: Tracks percentage of eye closure over rolling 30-second windows and blink rates (blinks/min) to prevent momentary blinks from triggering false alarms.
  • โšก Multimodal Stress Index (MSI: 0โ€“100): Fuses autonomic pulse elevation ($40%$), blink dynamics ($25%$), facial tension ($20%$), and head restlessness ($15%$) into a unified stress score with non-blocking desktop popups and guided breathing exercises.
  • ๐Ÿค– Local LLM AI Health Coach (Ollama / Llama-3 / Gemma-2): Ingests daily session analytics and generates personalized, empathetic ergonomics & wellness summaries with zero cloud API keys.
  • ๐ŸŸข Windows System Tray App & Smart Inactivity Standby:
    • Runs in the background at $1.0\text{ Hz}$ sampling cadence ($< 2-4%$ CPU utilization).
    • Automatically yields the camera when other apps (Zoom, Teams, OBS) open and reacquires it seamlessly.
    • Automatically stops, organizes logs into JSON/CSV, and enters deep $0%$ CPU standby after 15 minutes of absence, waking up instantly when you move your mouse.

๐Ÿ—๏ธ System Architecture

                               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                               โ”‚  Single Local Webcam Stream โ”‚
                               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚
                                              โ–ผ
                               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                               โ”‚ MediaPipe 468 3D Mesh + Irisโ”‚
                               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                      โ”‚       โ”‚       โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ–ผ                                โ–ผ                                โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚  1. Face & Gaze      โ”‚        โ”‚  2. AffectNet Model  โ”‚        โ”‚  3. rPPG Physiology  โ”‚
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
  โ”‚โ€ข 3D Head Pose (P/Y/R)โ”‚        โ”‚โ€ข 8 Emotion Classes   โ”‚        โ”‚โ€ข Forehead POS rPPG   โ”‚
  โ”‚โ€ข Iris Pupil Vector   โ”‚        โ”‚โ€ข Temporal EMA Filter โ”‚        โ”‚โ€ข Heart Rate (BPM)    โ”‚
  โ”‚โ€ข Screen Focus Score  โ”‚        โ”‚โ€ข Valence / Arousal   โ”‚        โ”‚โ€ข ISO PERCLOS Fatigue โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                               โ”‚                               โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                      โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚      Multimodal Stress Index & Real-Time Logger (1 Hz)        โ”‚
             โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
             โ”‚โ€ข SQLite Database (`tracker_history.db`)                       โ”‚
             โ”‚โ€ข Non-blocking Windows Desktop Alerts                          โ”‚
             โ”‚โ€ข System Tray Controller (`tray_app.py`)                       โ”‚
             โ”‚โ€ข Daily Local LLM Health Coach (`ai_coach.py`)                 โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ System & Hardware Requirements

Minimum Hardware

  • Processor: Intel Core i3 / AMD Ryzen 3 or higher (ARM64 supported)
  • RAM: 4 GB RAM minimum (8 GB recommended)
  • Camera: Any standard built-in or USB webcam ($720\text{p}$ or $1080\text{p}$, $30\text{ FPS}$)
  • GPU Acceleration: Compatible with all DirectX 12 GPUs (Intel Iris Xe, AMD Radeon, NVIDIA GeForce) via DirectML

Operating System

  • Windows 10 / 11 (Full support for System Tray, DirectShow camera sharing, and Windows input wake-up)
  • macOS / Linux (Full CLI & visual tracker support)

Core Python Dependencies (requirements.txt)

Package Version Purpose
opencv-python ~4.11.0 Camera frame acquisition & HUD rendering
mediapipe ==0.10.14 468 3D Facial Mesh & Refined Iris Landmarks
numpy 1.26.x High-speed array tensor & matrix calculations
scipy >=1.10.0 Butterworth bandpass filter & FFT signal processing
onnxruntime-directml >=1.18.0 GPU-accelerated DirectML deep learning inference
hsemotion-onnx >=0.3.1 AffectNet EfficientNet facial emotion recognition
pystray >=0.19.5 Windows System Tray notification area controller
pandas >=1.5.0 Session log analytics and CSV/JSON data export
Pillow >=10.0.0 Dynamic system tray icon image generator
requests >=2.28.0 Local Ollama LLM REST API client

๐Ÿš€ Quick Start

Installation

Option A: Install from PyPI (Recommended)

pip install ai-emotion-health-tracker

After installing, three commands become available globally:

ai-tracker         # Launch the visual HUD window
ai-tracker-tray    # Launch the silent system tray background mode
ai-tracker-coach   # Generate a daily AI health coaching report

Option B: Download Standalone .exe (No Python Required)

Download the latest release from the GitHub Releases page:

  • AI Tracker.exe โ€” Interactive visual HUD with live camera feed
  • AI Tracker Tray.exe โ€” Silent background system tray mode

No Python installation needed. Just download and double-click.

Option C: Clone from Source

git clone https://github.com/hklhfong/ai-emotion-health-tracker.git
cd ai-emotion-health-tracker
pip install -r requirements.txt

Prerequisites

  • Python 3.10, 3.11, or 3.12 installed
  • (Optional for deep LLM coaching) Ollama with ollama pull llama3 or ollama pull gemma2

Usage

Interactive Visual HUD Window

# If installed via pip:
ai-tracker

# If cloned from source:
python main.py
  • Press Q inside the camera window to save and exit.
  • Press E to export the live session directly to CSV.

Silent Background System Tray App

# If installed via pip:
ai-tracker-tray

# If cloned from source:
python tray_app.py
  • Minimizes directly into the Windows Notification Area tray.
  • Right-click the green circle icon to pause, ask the AI Coach, or view reports.

Daily AI Health Coach Insights

# If installed via pip:
ai-tracker-coach

# If cloned from source:
python run_coach.py

๐Ÿ“Š Database & Log Structure

All data is stored strictly on your local machine in tracker_history.db:

  • sessions: Start/end time, duration, average heart rate, dominant emotion, and total alerts.
  • metrics: 1-Hz time-series logging (BPM, emotion, EAR, MAR, head pose, focus score, stress level).
  • events: Timestamped camera states, high-stress popups, and drowsiness warnings.
  • session_reports/: Formatted JSON analytical breakdowns and CSV spreadsheets generated at the end of each session.

๐Ÿ› ๏ธ Tech Stack & Dependencies

  • Computer Vision: OpenCV, MediaPipe (468 FaceMesh + Iris)
  • Deep Learning / Accelerators: ONNX Runtime, DirectML, HSEmotion (AffectNet)
  • Signal Processing: SciPy (Butterworth Bandpass, FFT), NumPy
  • Data & UI: SQLite3, Pandas, Pystray, Pillow
  • Local AI: Ollama API (Llama-3, Gemma-2, Mistral)

๐Ÿ”’ Security Architecture & Privacy Disclosures

This repository is designed following Privacy-by-Design and Local-Only Zero-Trust principles:

1. Zero Cloud Transmission & No Video Recording

  • No Video Storage: Raw camera frames exist only in transient RAM buffers for immediate landmark calculation ($< 30\text{ ms}$) and are immediately discarded. No video files, images, or audio recordings are ever saved to disk.
  • Zero Telemetry / No External Calls: All neural network inferences (MediaPipe, AffectNet ONNX), signal filters, database logging, and LLM coaching queries run entirely on localhost. No data is transmitted across the network.

2. Open-Source Transparency & Anti-Malware Notice

  • 100% Plain Python Source: All code is open, auditable, and uses standard, official PyPI packages (opencv-python, mediapipe, onnxruntime-directml, scipy).
  • No Obfuscated Executables: No pre-compiled binary blobs (.exe or .dll) are included in the source tree to ensure verifiable safety.
  • Local SQLite Storage: Health metrics are stored in a standard unencrypted SQLite database (tracker_history.db) in your local project directory. Users can delete or inspect this file at any time.

โš•๏ธ Medical & Wellness Disclaimer

This software is an experimental wellness and productivity tracking tool. It is NOT a medical diagnostic device, clinical software, or certified medical monitor. Measurements such as rPPG heart rate, eye strain, and stress scores are approximations derived from computer vision algorithms and should not be used as a substitute for professional medical advice, diagnosis, or treatment.


๐Ÿ—๏ธ Building Standalone Executables

To build portable .exe files that run on any Windows machine without Python:

# Install build dependency
pip install pyinstaller

# Run the build script
python build_exe.py

# Or use the one-click batch file:
build_exe.bat

This produces two files in the dist/ folder:

  • AI Tracker.exe โ€” Visual HUD mode (with console)
  • AI Tracker Tray.exe โ€” System tray mode (no console)

๐Ÿ“ฆ Publishing to PyPI

For maintainers:

pip install build twine
python -m build
twine upload dist/*

๐Ÿ“œ License

MIT License. Feel free to use, modify, and contribute!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_emotion_health_tracker-1.0.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_emotion_health_tracker-1.0.0-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file ai_emotion_health_tracker-1.0.0.tar.gz.

File metadata

File hashes

Hashes for ai_emotion_health_tracker-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3e8c67656f910a46e042e98264315fdd9ff6aa7127d481ac4ba4b0925775cb16
MD5 0f1f762813f8b89b2e8bad942da35995
BLAKE2b-256 3708c334a8f2df8c116a1f32783a854d505c01f15c526ce29290a14a07632a09

See more details on using hashes here.

File details

Details for the file ai_emotion_health_tracker-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_emotion_health_tracker-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ca712eb847d20c1b80e57985df4891d94a7328f5c5e16a7264a3c28d01765c7
MD5 0a9e0150b862e8ed44ff81658c4b2779
BLAKE2b-256 abcf683db641cf4147ddaa41c184f0e5c39c6476edfb9d6a03631e567952cf9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page