How srinathsenthilkumar/real-time-hands-free-human-computer-interaction-via-eye-gaze-tracking-and-gestures works
Purpose and execution entry points
This is a Python 3.9+ desktop assistive-HCI application: webcam face/iris tracking drives OS cursor movement, mouse clicks, and scrolling. Likely runnable entry points are eye_gaze_hci/main.py for the packaged application flow and gaze_tracker.py as a top-level alternate/legacy launcher. Core package dependencies are declared in eye_gaze_hci/requirements.txt.
Application orchestration
eye_gaze_hci/main.py owns the real-time loop: acquire webcam frames, invoke face-landmark tracking, derive interaction state, issue system-control actions, and present visual feedback. It is the control boundary between computer-vision signals and irreversible host OS input events.
• eye_gaze_hci/main.py
• eye_gaze_hci/config.py
Face and iris landmark acquisition
MediaPipe Face Mesh is the perception engine, configured to use refined landmarks (including iris points) from camera images. OpenCV supplies capture and frame processing. The tracker should normalize raw per-frame landmarks into gaze/gesture measurements rather than exposing MediaPipe-specific structures throughout the app.
• eye_gaze_hci/tracker.py
• eye_gaze_hci/main.py
Gaze-to-cursor pipeline
Iris/eye geometry is transformed into screen-space coordinates, then smoothed with an exponential moving average to reduce jitter before cursor movement. Screen resolution and tuning thresholds are centralized configuration concerns, keeping calibration and sensitivity separate from the frame loop.
• eye_gaze_hci/tracker.py
• eye_gaze_hci/utils/math_utils.py
• eye_gaze_hci/config.py
Gesture interpretation and interaction modes
Facial micro-gestures form a discrete state layer over continuous gaze: left/right winks map to left/right clicks, while mouth opening (via mouth aspect ratio) toggles scrolling behavior. In scroll mode, vertical eye/head movement is interpreted as page scrolling rather than ordinary cursor-only control. Debouncing/cooldowns are architecturally important here to prevent repeated click or toggle events from consecutive frames.
• eye_gaze_hci/tracker.py
• eye_gaze_hci/config.py
• eye_gaze_hci/utils/math_utils.py
Host automation boundary
PyAutoGUI is the actuator integration: cursor positioning, button clicks, and scrolling are emitted as OS-level input. controller.py isolates these side effects from detection logic, allowing vision code to produce semantic commands instead of directly manipulating the desktop.
• eye_gaze_hci/utils/controller.py
• eye_gaze_hci/main.py
Visual runtime feedback
OpenCV-based visualization provides live camera output and likely draws landmarks, gaze indicators, or interaction status for calibration and user feedback. This display path is separate from OS control output and should not alter gesture decisions.
• eye_gaze_hci/utils/visualization.py
• eye_gaze_hci/main.py
Runtime and infrastructure
The system is local, CPU-oriented, and uses a standard webcam; no server, database, cloud service, GPU, or network dependency is indicated. Material external libraries are OpenCV, MediaPipe Face Mesh, NumPy, and PyAutoGUI.
• eye_gaze_hci/requirements.txt
• eye_gaze_hci/main.py
Main entry points: main.py Real-time loop · tracker.py Gaze tracker · math_utils.py Gaze math · config.py Tuning config
Components 14
Application Runtime
- Real-time loop · Coordinates frames, interaction, control, and feedback.
eye_gaze_hci/main.py - Tuning config · Centralizes screen, calibration, and gesture thresholds.
eye_gaze_hci/config.py - Dependencies · Declares the local Python runtime dependencies.
eye_gaze_hci/requirements.txt - Alternate launcher
gaze_tracker.py
Vision & Interaction
- OpenCV · Captures and processes camera frames.
- Gaze tracker · Normalizes landmarks into gaze and gesture measurements.
eye_gaze_hci/tracker.py - MediaPipe Face Mesh · Produces refined face and iris landmarks.
- Gaze math · Maps eye geometry and smooths cursor coordinates.
eye_gaze_hci/utils/math_utils.py - Gesture state · Interprets winks, mouth toggle, scrolling, and cooldowns.
eye_gaze_hci/tracker.py - Live visualization · Draws camera, landmarks, and interaction feedback.
eye_gaze_hci/utils/visualization.py
Host I/O
- Webcam
- OS controller · Converts semantic commands into desktop input.
eye_gaze_hci/utils/controller.py - PyAutoGUI
- Host desktop · Receives cursor, click, and scroll events.
Connections 16
- Webcam → OpenCV: camera frames
- OpenCV → Real-time loop: processed frames
- Real-time loop → Gaze tracker: analyze frame
- Gaze tracker → MediaPipe Face Mesh: refined landmarks
- Gaze tracker → Gaze math: iris/eye geometry
- Tuning config → Gaze math: screen and smoothing tuning
- Gaze math → Gesture state: smoothed gaze
- Gaze tracker → Gesture state: wink and mouth measures
- Tuning config → Gesture state: thresholds and cooldowns
- Gesture state → OS controller: cursor, click, scroll commands
- OS controller → PyAutoGUI: automation calls
- PyAutoGUI → Host desktop: OS input events
- Real-time loop → Live visualization: frame and interaction state
- Live visualization → OpenCV: render live feedback
- Dependencies → Real-time loop: declares runtime libraries
- Alternate launcher → Real-time loop: alternate application flow