FocusGuard is a desktop app for Windows, macOS and Linux that watches posture and focus through the camera and a local MLP, sending alerts while staying fully offline.
- 1.0.1
- Published at
- 6d ago
- 1
- Stars
- 9
- Download
Latest release
1.0.1Nov 29, 2026, 08:17 AMREADME
Project Overview
When you sit at a desk for hours writing code or reading documents and want something to watch your posture, FocusGuard keeps every decision on your own machine: Electron provides the window, MediaPipe runs face and pose landmarks inside the renderer, and a state that passes its threshold triggers an alert. Camera frames only pass through memory as numeric features, never as stored images, and nothing is uploaded. The main process owns windows and persistence, the renderer owns detection, training and charts, and the two talk over channels exposed by preload.js.
| Item | Value |
|---|---|
| Stack | Electron 28 with plain JavaScript |
| Vision models | MediaPipe Tasks Vision 0.10.22, one task model each for face and pose |
| Classifier | Self-trained MLP, 14 inputs, 24 hidden units, 8 outputs |
| Packages | macOS dmg / zip, Windows nsis / zip, Linux AppImage |
| License | MIT |
Frames never leave the machine, the model trains locally, and unplugging the network changes nothing.
Key Features
- Eight states: good posture, hunched back, leaning in, tilting, away, head down, off screen and distracted, each with its own colour, description and advice
- Two decision paths: rule mode judges by thresholds by default, or you collect and label samples on the training page and let a two-layer network take over
- Baseline calibration: after starting monitoring, sit up straight and press Calibrate baseline so later comparisons use that pose
- Tunable thresholds: sliders with limits for hunched back, leaning, tilt, off screen, head down and distraction, plus separate durations for away and inattention
- Alert control: desktop popups, locally synthesised chimes and system notifications can be combined, with a 20-second cooldown, 20 alerts per hour and a 5-minute snooze
- History and stats: daily records with snapshot thumbnails, and a stats page showing today's focus score, alert count, hour and type distribution, a 7-day trend and CSV export
- Window habits: optional start minimised, close to tray and launch at login
States and Default Thresholds
| State | Condition | Default |
|---|---|---|
| Hunched back | Head-to-shoulder distance drops by this ratio | 22% |
| Leaning in | Face area grows by this ratio | 24% |
| Tilting | Head tilt exceeds this angle | 12° |
| Off screen | Offset from screen centre exceeds this ratio | 28% |
| Head down | Downward gaze index deviates by this value | 20 |
| Distracted | Side gaze index deviates by this value | 16 |
| Away | No person detected for this many seconds | 5 s |
| Inattentive | Gaze off screen for this many seconds | 10 s |
Interface and Operation
- Six pages in the left navigation: Monitor, Training, History, Stats, Settings and Help
- The monitor page shows the camera preview, landmark overlay and a colour block for the current state, with landmarks toggleable
- The training page collects and labels samples for the eight states, then shows a confusion matrix and lets you switch the active model
- The camera defaults to 640x480 at 15 fps with a mirrored image; device and resolution are configurable
- A state must agree across at least 5 consecutive frames before it switches, which keeps jitter from raising false alerts
Quick Start
- Download the package for your platform from Releases; on macOS take
FocusGuard-1.0.1-arm64-mac.ziporFocusGuard-1.0.1-x64-mac.zip - Allow camera access on first launch; once the monitor page shows a picture, the MediaPipe models are ready
- Sit up straight, press Calibrate baseline, then run a day on the default thresholds before fine-tuning sensitivity
- For a self-trained model, label a few dozen frames per state on the training page and switch models under Settings → Model
- From source run
npm install(the script prepares WASM and downloads both landmark models, about 9 MB) and thennpm start;npm run checkruns the syntax check
Target Audience
- Office workers who sit for long stretches and feel it in the neck and shoulders
- Parents who want to nudge a child's posture
- Freelancers tracking how long they actually stay focused
- Developers exploring on-device pose estimation
System Requirements
| Item | Requirement |
|---|---|
| OS | Windows, macOS, Linux |
| Runtime | Electron 28, bundled with the installer |
| Running from source | Node.js 18 and above |
| Hardware | A working camera; MediaPipe prefers the GPU delegate and falls back to CPU |
Notes
- Not a medical assessment: thresholds come from pixel ratios and angles in the camera view, so recalibrate after changing chair or monitor height
- Camera placement matters: if the camera and the screen are not on the same plane, leaning and off-screen readings skew, so keep it centred above the display
- Rules and MLP disagree: a self-trained model depends on sample quality, and too few samples are less stable than the default thresholds
- Models need one online setup: the asset script fetches them from Google Storage, so on a blocked network copy both
.taskfiles intoassets/models/by hand - CPU fallback costs accuracy: when the GPU delegate fails, frame rate and detection responsiveness both drop