Gaze Control Banner # ๐Ÿ‘๏ธ Gaze Control **Hands-free scrolling for Android โ€” powered by real-time on-device eye tracking** [![Flutter](https://img.shields.io/badge/Flutter-3.11.5+-02569B?logo=flutter&logoColor=white&style=flat-square)](https://flutter.dev) [![Kotlin](https://img.shields.io/badge/Kotlin-Android-7F52FF?logo=kotlin&logoColor=white&style=flat-square)](https://kotlinlang.org) [![License](https://img.shields.io/badge/License-Apache%202.0-green?style=flat-square)](LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen?style=flat-square)](CONTRIBUTING.md) [![Platform](https://img.shields.io/badge/Platform-Android%2010+-3DDC84?logo=android&logoColor=white&style=flat-square)](https://android.com) [![MediaPipe](https://img.shields.io/badge/MediaPipe-Google-4285F4?style=flat-square)](https://developers.google.com/mediapipe) [**Read the Full Blog Post โ†’**](https://www.deepskylabs.in/portfolio/were-open-sourcing-gaze-control-hands-free-accessibility-for-everyone) ยท [Report a Bug](https://github.com/Deep-SkyLabs/gaze-control/issues) ยท [Request a Feature](https://github.com/Deep-SkyLabs/gaze-control/discussions)
Gaze Control Demo
--- ## Table of Contents - [Overview](#overview) - [Features](#features) - [Architecture](#architecture) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Running in Development](#running-in-development) - [Building a Release APK](#building-a-release-apk) - [Project Structure](#project-structure) - [Configuration Reference](#configuration-reference) - [Contributing](#contributing) - [Roadmap](#roadmap) - [Privacy](#privacy) - [License](#license) --- ## Overview Gaze Control is an Android accessibility utility that lets users scroll social media feeds โ€” Instagram, TikTok, YouTube Shorts, X/Twitter, Reddit โ€” using only their eyes, head movements, or palm gestures. It runs as an Android Foreground Service, processes all camera frames locally on-device via a [Google MediaPipe](https://developers.google.com/mediapipe) + L2CS-Net ONNX pipeline, and dispatches physical scroll gestures through the Android Accessibility Service API. No data ever leaves the device. Built for people who want hands-free mobile interaction: those recovering from surgery, living with motor disabilities, multitasking, or simply curious about what gaze-driven interfaces feel like. --- ## Features | Capability | Description | |:---|:---| | ๐Ÿ‘๏ธ **Eye Gaze Tracking** | Look up/down past a configurable dwell threshold to trigger scrolls | | ๐Ÿค™ **Head Nod State Machine** | Subtle vertical/horizontal nods fire instant scroll actions via gyroscope fusion | | ๐Ÿ–๏ธ **Palm Gesture Control** | Open Palm = Play/Pause ยท Closed Fist = Stop ยท Thumbs Up = Select | | ๐Ÿ“ **9-Stage Calibration** | Personalized neutral anchors, gaze extents, deadzones, and directional biases | | ๐Ÿ”’ **Full On-Device Privacy** | Camera frames processed in native memory, never stored or transmitted | | ๐Ÿ”‹ **Thermal-Aware Performance** | Dynamic frame throttling based on device temperature and tracking confidence | | โšก **NNAPI Acceleration** | L2CS-Net inference runs with hardware NPU acceleration + math fallback | | ๐Ÿ›ก๏ธ **Blink-Safe Tracking** | Eye Aspect Ratio + blendshape fusion prevents involuntary blinks from triggering actions | --- ## Architecture The system is split into two primary layers communicating via Flutter platform method channels. ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Flutter (Dart) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ GoRouter โ”€โ”€โ–บ Dashboard โ”€โ”€โ–บ Calibration โ”€โ”€โ–บ Settings โ”€โ”€โ–บ Onboarding โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Riverpod NotifierProviders โ—„โ”€โ”€ Platform Channel Adapters โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”˜ โ”‚ MethodChannel / EventChannel โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Kotlin (Android) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ GazeForegroundService โ”‚ โ”‚ โ”œโ”€โ”€ Camera2 API โ”€โ”€โ–บ MediaPipe Face/Hand Landmarker โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ–บ L2CS-Net ONNX (gaze pitch/yaw) โ”‚ โ”‚ โ”œโ”€โ”€ SensorEventListener โ”€โ”€โ–บ GravityRollDecoupler โ”‚ โ”‚ โ”‚ (head rotation โ‰  gaze intent) โ”‚ โ”‚ โ”œโ”€โ”€ CropStabilizer (EMA + affine alignment) โ”‚ โ”‚ โ”œโ”€โ”€ ConfidenceEngine (visibility + eyelid + gyro) โ”‚ โ”‚ โ”œโ”€โ”€ BlinkDetector (EAR + blendshapes) โ”‚ โ”‚ โ”œโ”€โ”€ DirectionHysteresis (entry/exit thresholds) โ”‚ โ”‚ โ”œโ”€โ”€ GazeStateMachine โ”‚ โ”‚ โ”‚ NO_FACE โ†’ SEARCHING โ†’ TRACKING โ†’ STABLE_LOCK โ†’ ACTION_READY โ”‚ โ”‚ โ”œโ”€โ”€ InteractionProfileManager (per-app scroll tuning) โ”‚ โ”‚ โ”œโ”€โ”€ ThermalPerformanceManager (dynamic frame throttling) โ”‚ โ”‚ โ””โ”€โ”€ AccessibilitySafetyEngine โ”‚ โ”‚ โ””โ”€โ”€โ–บ GazeAccessibilityService โ”€โ”€โ–บ System Gestures โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”˜ ``` ### Key Subsystems **`GazeForegroundService.kt`** โ€” The system heartbeat. Sticky foreground service that coordinates the full perception pipeline from frame capture to gesture dispatch. **L2CS-Net ONNX** โ€” Predicts high-resolution pitch/yaw gaze angles from MediaPipe eye ROI crops. Runs via `OnnxReflectiveRunner` with NNAPI hardware acceleration. **`GravityRollDecoupler`** โ€” Fuses accelerometer and gyroscope vectors to separate head rotation from genuine gaze intent. Essential for real-world usability when the device is not held perfectly upright. **`GazeStateMachine`** โ€” Prevents false positive gesture dispatch by enforcing the full state cycle: `NO_FACE โ†’ SEARCHING โ†’ TRACKING โ†’ UNSTABLE โ†’ STABLE_LOCK โ†’ ACTION_READY โ†’ COOLDOWN`. Actions only fire from `ACTION_READY`. **`ConfidenceEngine`** โ€” Combines landmark visibility scores, eyelid closure blendshapes, and device motion to generate a real-time 0.0โ€“1.0 tracking quality score. Suppresses the filter chain during low-confidence periods. --- ## Getting Started ### Prerequisites | Requirement | Version | |:---|:---| | Flutter SDK | `^3.11.5` | | Dart SDK | `^3.11.5` | | Android Studio | Latest stable | | Android SDK Platform Tools | `33+` | | Physical Android Device | API 29+ with front camera | > **โš ๏ธ Emulator Note**: Camera2 is unavailable on emulators. The app will launch but fall back to a degraded heuristic engine. Physical device testing is strongly recommended. ### Installation ```bash # 1. Clone the repository git clone (https://github.com/Deep-SkyLabs/gaze-control.git cd gaze-control # 2. Install Flutter dependencies flutter pub get # 3. Run code generators (Riverpod, GoRouter) flutter pub run build_runner build --delete-conflicting-outputs ``` ### Running in Development ```bash # Connect your Android device and verify it's visible flutter devices # Run in debug mode (note: CV pipeline is noticeably slower in debug) flutter run # Run in profile mode for realistic performance with debugging flutter run --profile ``` ### Building a Release APK ```bash # Build optimized release APK flutter build apk --release # The output APK will be at: # build/app/outputs/flutter-apk/app-release.apk ``` For App Bundle (recommended for Play Store distribution): ```bash flutter build appbundle --release ``` --- ## Project Structure ``` gaze-control/ โ”œโ”€โ”€ android/ โ”‚ โ””โ”€โ”€ app/src/main/kotlin/com/example/gaze/ โ”‚ โ”œโ”€โ”€ MainActivity.kt # Flutter โ†” Native MethodChannel bindings โ”‚ โ”œโ”€โ”€ GazeAccessibilityService.kt # Accessibility Service gesture dispatcher โ”‚ โ””โ”€โ”€ GazeForegroundService.kt # Full CV engine: camera, sensors, ML, state machine โ”œโ”€โ”€ lib/ โ”‚ โ”œโ”€โ”€ main.dart # App entry point โ”‚ โ””โ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ app/ โ”‚ โ”‚ โ””โ”€โ”€ app.dart # Root widget, theme injection โ”‚ โ”œโ”€โ”€ core/ โ”‚ โ”‚ โ”œโ”€โ”€ platform/ # MethodChannel / EventChannel adapters โ”‚ โ”‚ โ”œโ”€โ”€ services/ # Foreground service lifecycle controllers โ”‚ โ”‚ โ””โ”€โ”€ theme/ # Forui design token customization โ”‚ โ”œโ”€โ”€ routing/ โ”‚ โ”‚ โ””โ”€โ”€ app_router_config.dart # GoRouter declarations โ”‚ โ””โ”€โ”€ features/ โ”‚ โ”œโ”€โ”€ dashboard/ # Real-time telemetry & state visualization โ”‚ โ”œโ”€โ”€ gaze_tracking/ # Calibration wizard & diagnostic overlays โ”‚ โ”œโ”€โ”€ onboarding/ # First-launch welcome flow โ”‚ โ”œโ”€โ”€ permissions/ # Accessibility + overlay permission checks โ”‚ โ””โ”€โ”€ settings/ # Threshold configuration & app whitelisting โ”œโ”€โ”€ docs/ โ”‚ โ”œโ”€โ”€ assets/ # Banner, demo GIF, screenshots โ”‚ โ”œโ”€โ”€ ARCHITECTURE.md # Deep-dive architecture documentation โ”‚ โ””โ”€โ”€ CALIBRATION.md # Calibration system explained โ”œโ”€โ”€ test/ โ”‚ โ”œโ”€โ”€ unit/ # Dart unit tests โ”‚ โ””โ”€โ”€ widget/ # Flutter widget tests โ”œโ”€โ”€ CHANGELOG.md โ”œโ”€โ”€ CONTRIBUTING.md โ”œโ”€โ”€ LICENSE โ””โ”€โ”€ pubspec.yaml ``` --- ## Configuration Reference All user configuration persists in Android SharedPreferences: | Key | Type | Default | Description | |:---|:---|:---|:---| | `flutter.user_calibration_profile` | `String (JSON)` | `null` | Neutral gaze vectors, directional bounds, deadzones, and biases from the 9-stage calibration flow | | `is_first_launch` | `bool` | `true` | Controls whether the onboarding carousel renders on next launch | | `sensitivity` | `double` | `0.5` | Global gesture sensitivity multiplier `[0.1 โ€“ 1.0]` | Calibration profiles use the following JSON schema: ```json { "neutralPitch": 0.0, "neutralYaw": 0.0, "topThreshold": 0.18, "bottomThreshold": -0.18, "leftThreshold": -0.22, "rightThreshold": 0.22, "deadzonePitch": 0.06, "deadzoneYaw": 0.06, "verticalBias": 1.0, "horizontalBias": 1.0 } ``` --- ## Contributing Contributions are welcome. Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) before opening a pull request. ### Quick Contribution Guidelines - **Design tokens only**: All colors, spacing, and typography must use `context.theme` properties. No raw hex values. - **Explicit state**: Use `NotifierProvider` implementations. Avoid implicit provider reads in business logic. - **Lint compliance**: Run `flutter analyze` before submitting. The project uses strict linting rules in `analysis_options.yaml`. - **Tests**: Widget tests for new feature screens; unit tests for any new business logic in the `core/` layer. ### Good First Issues Look for issues tagged [`good first issue`](https://github.com/Deep-SkyLabs/gaze-control/labels/good%20first%20issue) โ€” these are scoped, well-documented, and don't require deep knowledge of the native CV pipeline. --- ## Roadmap - [ ] **Smart App Detection** โ€” Auto-wake camera service when a supported app enters foreground - [ ] **Context-Aware Smoothing** โ€” Dynamic One Euro Filter coefficients based on active scroll velocity - [ ] **Ambient Dynamic Theming** โ€” Mirror the active app's color palette in the Gaze Control overlay - [ ] **iOS Port** โ€” ARKit-based gaze engine for iPhone - [ ] **Passive Calibration Refinement** โ€” Incremental profile tuning over time without explicit recalibration sessions - [ ] **Additional Gesture Vocabulary** โ€” Tongue detection, expression triggers, breath sensing Track progress and vote on priorities in [Discussions โ†’ Roadmap](https://github.com/Deep-SkyLabs/gaze-control/discussions). --- ## Privacy Gaze Control is designed privacy-first by architecture: - Camera frames are processed in native memory and immediately discarded โ€” they are never written to disk - No gaze coordinates, usage events, or identifiers are transmitted off-device - The only persistent data is your calibration profile and settings, stored locally in Android SharedPreferences - The app requests no internet permission --- ## License Apache License 2.0 โ€” see [`LICENSE`](LICENSE) for full terms. ---
Built with care by **[Deep Skylabs](https://www.deepskylabs.in)** [Website](https://www.deepskylabs.in) ยท [Blog](https://www.deepskylabs.in/blog) *If Gaze Control has been useful to you, consider starring the repo โ€” it helps others find it.*
> โš ๏ธ **Early Development** โ€” This project is actively in development. Some features may be incomplete, unstable, or subject to breaking changes. Use in production at your own discretion.