face_gesture_detector
A Flutter widget that translates camera frames and MediaPipe facial landmarks into high-level semantic callbacks — exactly as GestureDetector translates pointer events into touch gestures.
Features
- FaceGestureDetector — Declarative facade with nullable callbacks per gesture family
- RawFaceGestureDetector — Power-user widget for custom recognizer maps
- 10 recognizers — Presence, Quality, Pose, Blink, Smile, Mouth, Brow, HeadTurn, HeadNod, RawFrame
- Temporal logic — Sustained-duration thresholds, cycle detection, state-transition filtering
- FaceGestureDetectorController — Imperative pause / resume / reset
- Configurable — All thresholds and durations via
FaceGestureConfiguration - Native Android — MediaPipe Face Landmarker with GPU delegate, single-slot backpressure, Euler angle extraction
Quick Start
import 'package:camera/camera.dart';
import 'package:face_gesture_detector/face_gesture_detector.dart';
// Minimal: presence detection only
FaceGestureDetector(
configuration: FaceGestureConfiguration(),
cameraController: cameraController,
onFaceDetected: (details) => print('Face found: ${details.confidence}'),
onFaceLost: () => print('Face lost'),
child: CameraPreview(cameraController),
)
// Full: all gesture families
FaceGestureDetector(
configuration: FaceGestureConfiguration(
blinkThreshold: 0.35,
smileThreshold: 0.5,
headTurnYawThreshold: 25.0,
sustainedGestureDuration: Duration(milliseconds: 400),
frameSkipCount: 2,
),
cameraController: cameraController,
controller: detectorController,
onFaceDetected: (d) => handleFace(d),
onFaceLost: () => handleLost(),
onBlinkDetected: (d) => handleBlink(d),
onSmileDetected: (d) => handleSmile(d),
onHeadTurnDetected: (d) => handleTurn(d),
onHeadNodDetected: (d) => handleNod(d),
onBrowRaised: (d) => handleBrow(d),
onMouthOpened: (d) => handleMouth(d),
onPoseChanged: (d) => handlePose(d),
onDistanceChanged: (d) => handleDistance(d),
onQualityChanged: (d) => handleQuality(d),
onFaceFrame: (frame) => handleRawFrame(frame),
child: CameraPreview(cameraController),
)
Architecture
Five-layer stack following Flutter's gesture system analogy:
| Layer | Class | Role |
|---|---|---|
| 1 | FaceGestureDetector |
Facade — callbacks → recognizer map |
| 2 | RawFaceGestureDetector |
Lifecycle — stream, recognizer management |
| 3 | Recognizers (BlinkRecognizer, etc.) |
Temporal gesture logic |
| 4 | FaceGestureDetectorPlatform |
Platform interface |
| 5 | Native (Kotlin + MediaPipe) | Camera + ML processing |
See doc/architecture.md for full details.
Status
v0.2.3 — Full end-to-end face gesture detection on Android with release build support.
xData model with 52 blendshapes, landmarks, pose anglesxPlatform interface (MethodChannel + EventChannel + processFrame)x10 recognizers with full test coveragexLayer 2 widget with frame routing, recognizer diff, controllerxLayer 1 facade with callback-to-recognizer mappingxNative Android — MediaPipe Face Landmarker (LIVE_STREAM + GPU delegate)xCamera integration —cameraControllerparameter wires the full pipelinexExample app — live camera preview with real-time gesture detectionxRelease build — ProGuard rules, sensor orientation compensationNative iOS
Libraries
- face_gesture_detector
- Face Gesture Detector — a Flutter widget that translates camera frames and MediaPipe facial landmarks into high-level semantic callbacks.