passive_liveness 0.1.1
passive_liveness: ^0.1.1 copied to clipboard
Ultra-lightweight passive face liveness detection using native TFLite (Google Play Services on Android, TensorFlowLiteSwift on iOS) for Flutter.
0.1.1 #
- Expanded Flutter & Dart Compatibility: Widened environment constraints to support Dart SDK
sdk: ">=3.0.0 <4.0.0"and Flutterflutter: ">=3.10.0".
0.1.0 #
- Low-Light Face Liveness Auto-Acceptance (
lowLightThreshold): Added configurable low-light auto-acceptance to eliminate false spoof rejections and errors in dark/dimly-lit environments (such as night shifts or low-light work spaces).lowLightThreshold(double?, defaultnull): When specified (e.g.70.0or0.30), frames captured with mean luminance below this threshold are automatically accepted as live (isReal: true,status: LivenessStatus.real), bypassing dark-induced neural logit suppression. Supports both 0..255 direct scale and normalized 0..1 scale.- Exposed Luminance Metrics:
LivenessResultprovidesmeanLuminance($0.0 \dots 255.0$) andisLowLightfor diagnostic logging and UI display.
- Upgraded Multi-Modal Anti-Spoofing Heuristics & Decision Fusion: Enhanced resilience against high-resolution OLED / Retina / MacBook screen replay attacks without increasing package size or native binary footprint.
- 2D Flatness Check (
is2DFlatSpoof): Evaluates Laplacian depth-of-field variance delta between center face crop ($\sigma^2_{\text{Face}}$) vs background region ($\sigma^2_{\text{Background}}$) to detect flat 2D focal planes ($\Delta < 0.08$). - Emissive Saturation Spikes (
isEmissiveSaturationSpoof): Converted color space crops to HSV to analyze Saturation ($S$) channel variance ($\text{varSat} \ge 0.045$) relative to Hue, identifying additive RGB display backlight scatter. - Fast 2D Radix-2 FFT Moiré Analyzer (
FftMoireAnalyzer): Pure Dart-only Cooley-Tukey FFT algorithm ($O(n \log n)$) to detect high-frequency sub-pixel display grid peaks ($\text{regularity} \ge 25.0$) beyond 60% Nyquist radius with zero binary size overhead. - Calibrated Multi-Factor Decision Fusion Engine: Re-calibrated decision override rules to reliably catch screen photo attacks (including low-brightness MacBook photos) while protecting genuine live face selfies under indoor lighting.
- Enhanced Debug & Watermark Metrics: Exposed
laplacianDelta,saturationVariance, andmoireHighFreqRatiometrics inLivenessResultfor detailed debugging and watermark logging.
- 2D Flatness Check (
0.0.6 #
- Direct
CameraImageLiveness API Support (detectLivenessFromCameraImage): Added directCameraImageevaluation support toPassiveLivenessDetector, eliminating redundant developer boilerplate for converting camera frames toLivenessImageBuffer.
0.0.5 #
- Native MethodChannel TFLite Architecture (~0MB Android APK Impact): Migrated model inference from
flutter_litertDart FFI to native platform channels (com.andikatp.passiveLiveness), reducing plugin binary size footprint from ~40MB down to almost 0MB.- Android: Uses Google Play Services TFLite runtime (
play-services-tflite-java:16.5.0&play-services-tflite-gpu:16.5.0), eliminating ~40MB APK/AAB size bloat by utilizing system-shared TFLite binaries with automatic GPU acceleration & CPU fallback. - iOS: Uses Apple-thinning optimized
TensorFlowLiteSwift (~> 2.14)targeting iOS 12.0+.
- Android: Uses Google Play Services TFLite runtime (
- Zero-Dependency Plugin Architecture: Completely removed third-party
flutter_litertdependency. - Pure Dart Heuristic Processing: All anti-spoofing heuristic layers (
FaceProximityGate,LbpHogAnalyzer,ColorSpaceAnalyzer,HighResScreenAnalyzer, andImagePreprocessor) remain 100% in Dart for zero-overhead performance. - Lower-end Device Compatibility (Low Light & High Sensor Noise): Re-enabled automatic brightness adjustment (
enableContrastStretch) in the main inference pipeline to improve neural model accuracy on budget phones with dark environments. - Chrominance Variance & Heuristic Decision Tuning: Calibrated
ColorSpaceAnalyzer.maxVarianceThresholdto140.0and upgraded multi-factor decision fusion to reliably capture subtle OLED screen replays (e.g.spoof4) while eliminating false spoof rejections on genuine faces. - Cleaner Diagnostics: Streamlined
LivenessLoggerto reflect Native Platform Channel engine initialization. - Enhanced
.gitignore: Added full coverage for Android and iOS build output directories (.gradle/,Pods/,DerivedData/, etc.).
0.0.4 #
- High-Resolution Screen Replay Anti-Spoofing (
HighResScreenAnalyzer): Added 2D Laplacian frequency variance and patch focus depth dispersal ($\sigma^2_{\text{PatchLap}}$) analysis to catch high-resolution OLED/Retina/4K screen replay presentation attacks. - Glasses Glare & Frame Edge False Positive Resolution: Added specular glare highlight masking ($\ge 245$ brightness) and multi-region upper-face HOG peak de-biasing (
LbpHogAnalyzer&ColorSpaceAnalyzer) to prevent linear glasses frames and anti-reflective lens glare from triggering false spoof classifications on genuine users. - Multi-Factor Liveness Decision Fusion Engine: Upgraded
PassiveLivenessDetectordecision engine to use multi-factor fusion scoring with adaptive neural model thresholding. - Zero-Config Default Heuristic Engines: All anti-spoofing heuristic layers (
enableTextureAnalysis,enableColorSpaceAnalysis,enableHighResScreenAnalysis) are now enabled by default (true). - Streamlined API Parameter Signatures: Cleaned up redundant internal low-level flags across
detectLivenessFromImageBytes,detectLivenessFromImageFile,detectLivenessFromBuffer, andLivenessFrameProcessor.processBufferFramefor a zero-boilerplate developer experience. - Face Aspect Ratio & Proximity Gate: Added early pre-inference rejection gate (
FaceProximityGate) to discard presentation attacks with small cropped photos ($<5%$ area), extreme close-ups ($>85%$ area), or distorted aspect ratios ($0.50 \dots 1.25$). - Micro-Texture LBP / HOG Analysis Engine: Added
LbpHogAnalyzerto evaluate $256 \times 256$ un-downscaled face crops for paper inkjet print halftone patterns (Local Binary Patterns) and screen grid alignments (Histogram of Oriented Gradients). - YCbCr / YUV Color Space Analysis: Added
ColorSpaceAnalyzerto calculate chrominance sub-sampling variance ($\sigma^2_{CbCr}$) directly from YUV camera streams to detect emissive RGB digital display screen replay attacks (iPad/tablet video replays). - Adaptive Screen Flash Overlay: Added
LivenessFlashControllerandAdaptiveScreenFlashOverlayUI components for active photometric stereo assist. - New
LivenessStatusDiagnostic Reason Codes: IntroducedtooFar,tooClose,invalidAspectRatio,printSpoof, andscreenReplaySpoofto give developers detailed status feedback.
0.0.3 #
- Android Sensor Coordinate Rotation & Accuracy Fixes: Fixed coordinate transformation for Android ML Kit portrait face bounding boxes across all sensor angles (
0°,90°,180°,270°), ensuring accurate upright crops and resolving false spoof detections on Android devices. - Low-Light & Dark Environments Compensation: Enhanced anti-spoofing accuracy in dim lighting using adaptive power-law gamma expansion ($\gamma \approx 0.60 - 0.88$) and dynamic contrast stretching without corrupting facial texture liveness signals.
- Glasses Glare & Specular Reflection Resilience: Implemented Asymmetric Exponential Moving Average (EMA) score filtering ($\alpha=0.1$ for score drops, $\alpha=0.4$ for recovery) to prevent momentary specular lens reflections on glasses from triggering false spoof classifications.
- LiteRT Next
CompiledModelZero-Copy Acceleration: Integrated LiteRT NextCompiledModelsupport for zero-copy GPU/CPU hardware acceleration with automatic fallback to classicInterpreter. - Flexible Model Tensor Layout Support: Added automatic shape inspection to support both NCHW (
[1, 3, H, W]) and NHWC ([1, H, W, 3]) tensor models. - Edge Pixel Replication (
BORDER_REPLICATE): Improved image preprocessor boundary handling to eliminate pitch-black border artifacts on tight face crops. - Pending Result & EMA Tracker Controls: Added
LivenessResult.pending()factory constructor andresetEma()controls for handling motion transition frames cleanly.
0.0.2 #
- Fix Android ML Kit Bounding Box Coordinate System Mismatch: Fixed false spoof classification on Android caused by portrait bounding box offsets. Added
isRotatedBoundingBoxparameter andFaceBoundingBox.toRawBufferSpace()transformation for0°,90°,180°, and270°sensor angles. - Fix Android 270° Front Camera Upside-Down Crop: Corrected
case 270coordinate mapping inImagePreprocessorto ensure MiniFAS receives upright face crops. - Offload Inference to Background Isolate (
IsolateInterpreter): Prevented main UI isolate frame drops by running LiteRT inference asynchronously on a dedicated background Dart isolate. - Add XNNPack ARM NEON SIMD Hardware Vectorization: Enabled
XNNPackDelegatefor 2x–4x CPU matrix multiplication speedup on mobile chipsets. - Fast NV21 Plane Copy: Optimized
_getNv21Bytesto replace 518,400 Dart loop iterations with nativesetRangearray copies. - Low-Light Adaptive Gamma Contrast Expansion: Replaced linear boost with adaptive power-law gamma curve ($\gamma \approx 0.60 - 0.88$) to expand 3D skin texture gradients in dim lighting.
0.0.1 #
- Initial release of
passive_liveness. - Ultra-lightweight passive face anti-spoofing engine powered by LiteRT (TensorFlow Lite) edge inference.
- Real-time zero-copy camera frame processing (
LivenessImageBuffer) for high FPS video streams (iOSBGRA8888, AndroidNV21/YUV420). - Support for static image file (
File) and byte array (Uint8List) liveness detection (e.g. fromtakePicture()orimage_picker). - Closed-form
reflect101boundary padding and camera sensor rotation sampling (0°,90°,180°,270°). - Built-in low-light shadow-lift compensation for underexposed camera environments.