face_detection_camera 0.3.1
face_detection_camera: ^0.3.1 copied to clipboard
Smart Flutter camera with face detection, look-straight constraints, auto-capture, and customizable overlay.
Changelog #
0.3.1 #
New Features #
- Per-challenge image capture: Each
LivenessChallengeResultnow includes acapturedImagefield, captured at the moment the challenge completes or fails. - Configurable
challengeDelay: Delay between challenges is now customizable viaLivenessCameraWidget.challengeDelay(default: 500ms).
Improvements #
- Safer image processing:
_processImageIsolatenow deletes the file after successful decode instead of before, preventing permanent image loss on decode failure. LivenessResult.capturedImageis now set from the last challenge's image (no extra capture call).
Bug Fixes #
- Liveness
capturedImagealways null:LivenessController._completeFlow()now captures an image viacaptureCallbackbefore creatingLivenessResult, populated on both pass and fail. autoStart = falseunusable: Added a "Start" button UI whenautoStartisfalse, and exposedstartLiveness()method on_LivenessCameraWidgetState.- Crash after dispose (async
_completeFlow): Added_isDisposedguard throughoutLivenessControllerto prevent accessing disposed ValueNotifiers after async operations. - Crash from
Future.delayedafter pop:_successChallengenow guards the 500ms delay with_isDisposedand state checks. _holdTimerpasses challenge without face: AddedonFaceLost()method;LivenessCameraWidgetcalls it when face becomesnull, cancelling the hold timer.- Missing app lifecycle handling: Added
WidgetsBindingObservertoLivenessCameraWidgetto pause camera & cancel timers on background. - Anti-spoofing too strict: Replaced instant-fail on tracking ID change with tolerant
maxTrackingIdChanges(default: 3). - Capture state collision:
FaceCameraController.capture()now uses aCompleterso concurrent calls wait for the ongoing capture instead of returning silently. - Wrong default threshold for turn/nod:
LivenessChallengeConfig.thresholdnow defaults to 20° for turn/nod challenges (was 0.5, which meant any tiny movement would pass).
0.3.0 #
New Features #
- Liveness Detection: Integrated a flexible banking-app style liveness flow with customizable challenges (blink, smile, turn left/right, nod up/down).
- LivenessCameraWidget: New specialized widget for handling the entire liveness flow with built-in UI and animations.
- Bilingual Documentation: Added comprehensive API comments in both English and Vietnamese.
Architectural Improvements #
- Modular Refactoring (SRP): Decomposed the monolithic controller and widget into specialized services:
CameraService: Manages camera lifecycle, flash, and zoom.FaceDetectionService: Handles ML Kit integration and face data processing.StabilityTracker: Manages face stability and capture countdown.LivenessController: Orchestrates challenge sequencing and flow.
- Sub-widget Extraction: Moved complex UI components into modular sub-widgets for better maintainability.
Bug Fixes & Optimizations #
- App Lifecycle Handling: Fixed camera issues when moving the app to background/foreground.
- Memory Management: Ensured proper disposal of all controllers and ValueNotifiers to prevent leaks.
- Double File Deletion: Resolved a redundant file delete operation during the capture flow.
- Improved Metrics: Refined
FaceQualitycalculations with a more stable brightness estimation. - Enhanced Customization: Exposed all internal thresholds, colors, icons, and builders as parameters.
0.2.0 #
New Features #
- Multiple Face Detection: Added
detectMultipleFaces,maxFaces, andonMultipleFacesDetectedcallback - Face Quality Score: Added
FaceQualityclass with brightness, sharpness, and pose metrics - Manual Capture Button: Added
showCaptureButtonandcaptureButtonBuilderfor custom UI - Preview Mode: Added
showPreview,onPreviewConfirm, andonPreviewRetrycallbacks - Zoom Control: Added pinch-to-zoom with
enableZoom,minZoom,maxZoom, andzoomLevelnotifier - Capture Sound: Added
enableCaptureSoundoption
Optimizations #
- Error Recovery: Auto-retry camera initialization with exponential backoff (
maxRetryAttempts) - Memory: Proper disposal of all ValueNotifiers and resources
0.1.0 #
- Initial public release with basic face detection and auto-capture.