A real-time computer vision system that detects Digital Eye Strain using facial landmark analysis, blink detection, and a deep learning classifier trained on ~16,000 images. Built as a third-year dissertation project at Lancaster University.
Achieved ~92% accuracy / F1 on the test set — exceeding the supervisor's target of ~80%. Runs cross-platform on macOS and Windows with popup notifications and session logging.
📹 Add a screen recording or GIF of the system running here
| Metric | Value |
|---|---|
| Accuracy | ~92% |
| F1 Score | ~92% |
| Training images | ~16,000 |
| Inference | Real-time |
| Platforms | macOS, Windows |
- EfficientNet-B0 classifier — transfer learning on a combined dataset, outperforms ResNet-18 baseline
- Eye aspect ratio (EAR) — blink rate detection via MediaPipe Face Mesh landmarks
- Red eye detection — HSV colour space analysis for scleral redness
- Distance estimation — screen-to-face distance monitoring derived from facial geometry
- Arm stretch detection — MediaPipe Pose integration for break reminders
- Lighting analysis — ambient light level detection for environment feedback
- Rule-based DES decision logic — multi-signal decision module with a recommendation engine
- Cross-platform notifications — a pop-up notification system built as a subprocess (handles macOS tkinter threading constraints)
- Session logging — CSV export of sessions and recommendations over time
The system runs a main loop capturing webcam frames and passing them through three parallel pipelines:
- Deep learning classifier — EfficientNet-B0 predicts DES state from the face crop
- Conventional CV feature extraction — EAR blink rate, HSV red-eye score, face-to-screen distance, and ambient lighting level
- Pose estimator — MediaPipe Pose detects body posture and arm position for stretch reminders All outputs feed into a rule-based decision module that triggers notifications and logs the session to CSV.
| Category | Libraries / Tools |
|---|---|
| Deep learning | PyTorch, EfficientNet-B0 (transfer learning) |
| Computer vision | OpenCV, MediaPipe Face Mesh, MediaPipe Pose |
| Feature engineering | NumPy, HSV colour analysis |
| Notifications | tkinter (subprocess), platform-native popups |
| Logging | CSV (sessions + recommendations) |
| Language | Python 3.10+ |
- Python 3.10+
- Webcam
- macOS 13+ or Windows 11
git clone https://github.com/YOUR_USERNAME/des-detection.git
cd des-detection
pip install -r requirements.txtpython main.pyThe system will open your webcam and begin monitoring in real time. Notifications will appear when DES indicators are detected.
des-detection/
├── test_webcam.py # Entry point — main detection loop
├── classifier/ # EfficientNet-B0 model and training scripts
├── features/ # EAR, HSV, distance, lighting modules
├── pose/ # MediaPipe Pose integration
├── decision/ # Rule-based DES decision module
├── notifications/ # Cross-platform popup system
├── logging/ # Session and recommendation CSV logger
├── data/ # Dataset preparation scripts
├── requirements.txt
└── README.md
Why EfficientNet-B0 over ResNet-18? EfficientNet-B0 achieves higher accuracy with fewer parameters by simultaneously scaling width, depth, and resolution (Tan & Le, 2019). Empirically, it outperformed ResNet-18 on this dataset while remaining fast enough for real-time inference.
Why rule-based decision logic? A learned classifier for the final DES decision would require labelled multi-signal sequences, for which no suitable public dataset exists. A rule-based module is transparent, easily tunable, and interpretable — important for a health-adjacent application.
Why conventional methods for some features? EAR, HSV redness, and distance estimation are well-understood, robust, and require no training data. Using deep learning for these signals would add complexity without meaningful accuracy gains.
Developed as part of the SCC.300 Third Year Project at Lancaster University.