flutter_face_liveness_detection 0.2.8
flutter_face_liveness_detection: ^0.2.8 copied to clipboard
On-device face liveness detection for Flutter with randomized active challenges and multi-signal passive anti-spoofing.
Changelog #
0.2.8 #
- Fix: the instant-capture image (
fastCapture) came out upside down / sideways. It now uses its own upright rotation per platform (Android raw sensor frames, iOS frames that arrive already upright and mirrored) instead of ML Kit's rotation value. - Add
LivenessConfig.fastCapture(defaulttrue): the final image is built from the latest camera frame where the face was straight (straightPoseMaxDeg, default12), encoded on a background isolate. NopreCaptureDelaypause, no shutter, no stream restart - capture takes milliseconds instead of ~1-2 s. Image is at preview resolution; setfastCapture: falsefor the previous full-resolutiontakePicturestill. passiveFrameCountdefault lowered from12to8for a faster no-challenge session.- The result is returned before the camera stream finishes stopping.
- One session at a time: add
LivenessScreen.open(context, ...), which returnsnullwithout pushing if a screen is already open, andLivenessScreen.isOpen. A secondLivenessScreenpushed while one is showing closes itself without opening the camera. - Closing the screen (close button, back gesture, or result) always
releases the camera, ML Kit detector and sensors. A new session waits for
the previous one's camera to be released before opening it, and a pending
start()completes ascancelledondispose(). - Behaviour change:
LivenessScreenno longer shows the "Verified" / "Verification failed" message or result card when a session ends - it just closes and returns theLivenessResult. PassshowResult: true(also onLivenessScreen.open) to bring them back;showCapturedImagePreviewonly applies withshowResulton. - Refreshed
LivenessScreendesign: top bar with round close button and title (messages.title); oval frame that is white while the face needs adjusting and green once it is positioned; a Face ID-style tick ring around the oval that lights up with progress (also in no-challenge sessions, via the newLivenessState.scanProgress); a scan line sweeping the face while a step runs; the instruction in a frosted-glass card with a per-step icon (spinner while starting or checking); step dots under the instruction; and a privacy footer (messages.privacyNote, empty hides it). "No face detected" now reads as the fix ("Position your face in the oval"). - The debug face box and landmark dots are off by default; pass
showFaceOverlay: truetoLivenessScreento show them. - Example app: starts with no challenges and mask detection off, and opens
the screen through
LivenessScreen.open.
0.2.6 #
- Challenges are now optional: pass
challengeCount: 0(or an emptychallengePool) to skip active challenges entirely. The session collects face frames, then scores on the passive anti-spoof signals only (brightness, sharpness, glare, texture, micro-motion, mask check). PreviouslychallengeCountwas clamped to at least 1 and an empty pool fell back to a blink challenge. - Add
LivenessConfig.passiveFrameCount(default12): frames to collect before scoring when no challenges are requested. Capped atanalysisWindow. - Example app: challenge picker now allows deselecting every challenge.
0.2.5 #
- Add
LivenessConfig.messages(LivenessMessages): every user-facing string the package shows - status copy ("Position your face in the oval", "Hold still", "Checking", ...), per-challenge instructions (includingholdStillInstruction, default'Hold still and look at the camera'), result-card copy for eachLivenessFailure, and the error panel/permission copy - is now overridable without forking the UI. Every field defaults to the current copy, so leavingmessagesunset changes nothing. LivenessConfig.instructionBuilderstill takes priority overmessages's per-challenge fields when both are supplied.
0.2.3 #
- Add
requireFaceInOval(defaultfalse): when on, a detected face outside the on-screen capture oval is treated like "no face" - challenges won't advance and the final still won't be captured - until it's recentred. - Captured still now crops to the face by default (
cropToFace, defaulttrue) instead of saving the full camera frame, using the last known-good face box from the session plus a configurable margin (faceCropPadding, default0.4). SetcropToFace: falsefor the old full-frame capture. - Add
LivenessScreen.showCapturedImagePreview(defaultfalse): shows a thumbnail of the captured still on the result card when the session passes. - Add
ovalCrop(defaulttrue): whencropToFaceis on, the captured still is cropped to the on-screen oval's bounding box with everything outside the ellipse painted black, instead of a padded rectangle around the face box. SetovalCrop: falsefor the old rectangular face crop. - Oval size/position is now configurable:
ovalWidthFraction(default0.72, fraction of screen/frame width),ovalHeightRatio(default1.32, oval height as a multiple of its width), andovalCenterYFraction(default0.4, vertical center as a fraction of height from the top). Drives the on-screen oval, therequireFaceInOvalgate, and theovalCropcapture shape consistently. - Add
captureCropScale(default1.0): shrinks (or grows) just theovalCropcapture area around the oval's center, independent of the on-screen guide oval - e.g.0.8crops the final still tighter on the face while the displayed oval stays the same size.
0.2.1 #
- Add
preCaptureDelay(default 900ms): a "Hold still" pause between the last challenge passing and the final photo, so the still isn't snapped mid-turn right after a turn/nod challenge. Set toDuration.zerofor the old instant-capture behaviour.
0.2.0 #
- Add mask detection: a worn mask flattens the nose/mouth region relative to
the eyes/forehead, and the analyzer now watches for that texture drop every
frame. A session that looks masked for too long, or too consistently, fails
fast with
LivenessFailure.maskDetectedinstead of completing challenges or capturing a photo. Tunable viaenableMaskDetection,maskDetectionFrames,maskTextureRatio,maskEntropyDrop,maskSessionFraction. - Face detector now defaults to ML Kit's
FaceDetectorMode.fastfor quicker per-frame detection on mid-range devices.
0.1.1 #
- Add screenshots to README.
0.1.0 #
- Initial release: on-device face liveness detection with randomized active challenges (blink, smile, turn left/right, nod down, hold still) and a multi-signal passive anti-spoof analyzer (brightness, sharpness, glare, texture, micro-motion, motion correlation, depth parallax).
- Optional pluggable
AntiSpoofModelfor a trained network signal.
