feat: realtime face detection for filter overlays
RI
8d ago+1201+1201+0123456789012345678901234567890123456789-60-60-01234567890123456789
Fixes #200
What
- Add
startFaceDetection/stopFaceDetectionandfaceDetected/faceDetectionErrorevents. - Emit normalized face bounds (0 to 1, top-left origin) for overlay placement.
- Support optional
faceDetectiononCameraPreview.start().
Why
- Issue #200 requests realtime face position for Snapchat-style filters.
- Still-image ML plugins do not cover live preview frames.
How
- Android: ML Kit face detection on a CameraX
ImageAnalysispipeline (mirrors barcode scanning). - iOS: Vision
VNDetectFaceRectanglesRequeston the existing video data output. - Web: Shape Detection
FaceDetectorwhen the browser exposes it. - TypeScript API and docgen in
src/definitions.ts.
Testing
bun run buildbun run fmtandbun run lintbun test(includesFaceDetectionJsonMapperTestandface-detection-api.test.ts)
Not Tested
- On-device filter overlay UX (no physical device in this run).
- iOS
xcodebuild(Linux agent; CI covers iOS).


![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by CodeRabbit
- New Features
- Added face detection on Android, iOS, and supported web browsers that expose the
FaceDetectorAPI. Detection can be enabled when starting the camera or controlled separately. - Face results include normalized bounding boxes and optional tracking IDs. Detection errors are reported through a separate event.
- Detection runs at a default 100 ms interval, which can be adjusted.
- Added face detection on Android, iOS, and supported web browsers that expose the
- Documentation
- Added face-detection setup, options, events, platform availability, and result details to the API documentation.
- Tests
- Added coverage for face-bound normalization and the public face-detection API.