A real-time concentration tracking system built using MediaPipe and OpenCV. This tool evaluates a user's attentiveness based on eye blinks, gaze direction, and head pose — ideal for applications like study monitoring, e-learning, or productivity enhancement.
-
Eye Blink Detection
Calculates Eye Aspect Ratio (EAR) to detect blinks and periods of eye closure. -
Gaze Detection
Estimates if the user is looking straight or away using iris landmarks. -
Head Pose Estimation
Evaluates user orientation based on nose position relative to screen center. -
Concentration Score
Computes a weighted score combining gaze, head pose, and blinking behavior. -
Live Visual Feedback
Real-time UI overlay on webcam feed showing concentration level, blink status, and distraction counter. -
Distraction Tracking
Counts how many frames the user is not paying attention and issues warnings if needed.
The video feed displays:
- A concentration percentage bar
- Blink detection alerts
- Distraction count
- ACTIVE / DISTRACTED indicator
- FPS counter
- Python 3.x
- OpenCV
- MediaPipe (FaceMesh)
- NumPy
- Face landmarks are detected using MediaPipe FaceMesh.
- EAR (Eye Aspect Ratio) is used to detect blinks.
- Iris position is used to assess gaze direction.
- Nose position is used to infer head pose.
- A composite concentration score is calculated as: score = 0.4 * gaze + 0.4 * head_pose + 0.2 * (not blinking)
- A visual feedback system shows user concentration in real time.
git clone https://github.com/whuang369/concentration_tracker.git
cd concentration_tracker
pip install -r requirements.txt
python concentration_tracker.py