Skip to content
Ranveer Singh Gour edited this page Jun 20, 2026 · 1 revision

Gesture Canvas Input

Production-grade gesture input for Flutter canvases using hand tracking, built with a strong focus on architecture, reliability, latency, and user experience.


Overview

Gesture Canvas Input is a web-first Flutter plugin that transforms hand-tracking data into a clean, platform-agnostic canvas input system.

The goal is not simply to detect gestures. The goal is to create an input architecture where a canvas can be controlled by different input sources—mouse, touch, stylus, or hand tracking—without changing canvas logic.

This project is intentionally designed as a quality-focused engineering exercise. Every feature must meet production-grade standards for reliability, testing, failure handling, and maintainability.


Project Goals

Primary Goals

  • Convert hand gestures into canvas interactions.
  • Maintain complete separation between gesture recognition and canvas behavior.
  • Deliver predictable low-latency interaction.
  • Provide deterministic testing without camera hardware.
  • Offer a simple and intuitive Flutter API.

Non-Goals

  • General-purpose gesture recognition.
  • Full-body tracking.
  • Sign language interpretation.
  • Mobile-native implementations (initially web-focused).
  • AI model training or customization.

Core Architecture

The architecture is built around a single abstraction:

CanvasInputSource

Every input method communicates with the canvas through this boundary.

Examples:

  • MouseInputSource
  • GestureInputSource
  • Future TouchInputSource
  • Future StylusInputSource

The canvas never receives raw hand landmarks, MediaPipe objects, or camera-specific data.

Architecture Flow

Camera
   ↓
MediaPipe Hand Landmarker
   ↓
Gesture Interpreter
   ↓
GestureInputSource
   ↓
CanvasInputController
   ↓
Canvas Widgets

This separation allows:

  • Hardware-independent testing
  • Input source replacement
  • Replay-based debugging
  • Cleaner API design

Design Principles

No Undefined States

Every operation must have explicit success and failure behavior.

Examples:

  • Camera permission denied
  • Camera unavailable
  • Model loading failure
  • Tracking loss
  • Inference interruption

No silent failures.


Visible System State

Users should always understand what the system is doing.

Examples:

  • Hand detected
  • Tracking active
  • Hover state
  • Pinch active
  • Tracking lost

Test Through Boundaries

All gesture behavior must be testable without camera hardware.

Recorded landmark streams should be replayable through the input boundary.


API First

The public API is considered a product.

Requirements:

  • Safe defaults
  • Discoverable configuration
  • Sensible naming
  • Minimal setup
  • Comprehensive documentation

Strict Encapsulation

Hand-tracking implementation details must never leak beyond:

GestureInputSource

Raw landmarks should remain internal implementation details.


Development Roadmap

Phase 0 — Foundations

Objectives

  • Create Flutter package structure
  • Configure CI
  • Configure linting
  • Create example application

Production Criteria

  • CI passes on every commit
  • Zero analyzer warnings
  • Standard package structure
  • Known limitations documented

Phase 1 — Input Boundary

Objectives

  • Implement CanvasInputSource
  • Implement MouseInputSource
  • Build example canvas
  • Validate architecture

Production Criteria

  • Canvas remains input-agnostic
  • Immutable events
  • Deterministic tests
  • No resource leaks

Phase 2 — Detection Pipeline

Objectives

  • Camera integration
  • MediaPipe hand detection
  • Web Worker inference
  • Latency measurement

Production Criteria

  • Main UI thread remains responsive
  • Proper cleanup of camera resources
  • User-visible error states
  • Measured latency reporting

Phase 3 — Gesture Interpretation

Objectives

  • Gesture state machine
  • Hysteresis handling
  • Smoothing filters
  • Velocity prediction
  • Replay testing

Production Criteria

  • No threshold chatter
  • Stable drag interactions
  • Graceful tracking recovery
  • Debug visualization tools

Phase 4 — Canvas Integration

Objectives

  • GestureInputSource integration
  • Pinch-to-drag interaction
  • Two-hand zoom support
  • Visual cursor feedback

Production Criteria

  • No accidental activation
  • Tracking quality monitoring
  • Safe fallback to mouse input
  • Clear interaction states

Phase 5 — Hardening & Release

Objectives

  • Inclusivity testing
  • Calibration workflow
  • Documentation
  • Package publication

Production Criteria

  • Cross-environment validation
  • User calibration under 10 seconds
  • Complete README
  • Production example application

Performance Targets

Metric Target
Inference FPS 30+ FPS
Perceived Latency < 50 ms
UI Thread Blocking 0 ms
Camera Cleanup Deterministic
Gesture Chatter None

Testing Strategy

Unit Tests

Validate:

  • Input controller behavior
  • Gesture state transitions
  • Hysteresis logic
  • Replay fixtures

Integration Tests

Validate:

  • Camera lifecycle
  • Source switching
  • Resource cleanup

Replay Tests

Recorded landmark sequences should reproduce bugs and edge cases deterministically.

Examples:

  • Pinch while moving
  • Tracking loss during drag
  • Multiple hands appearing
  • Rapid gesture changes

Known Constraints

Current project limitations include:

  • Web-first implementation
  • Dependency on MediaPipe hand tracking
  • Performance varies by hardware
  • Tracking quality affected by lighting conditions

Additional limitations will be documented as the project evolves.


Contribution Guidelines

Before submitting a pull request:

  1. Run all tests.
  2. Pass static analysis.
  3. Add documentation for public APIs.
  4. Maintain boundary separation.
  5. Add tests for new behavior.
  6. Avoid introducing undefined states.

Contributors should prioritize reliability, maintainability, and user experience over feature count.


Philosophy

The objective of this project is not to implement every possible gesture.

The objective is to build a small set of interactions that feel reliable, predictable, and production-ready.

Quality is achieved not by adding features, but by ensuring every shipped feature behaves correctly under real-world conditions.