smart_selfie_capture library
Smart Selfie Capture - A comprehensive Flutter package for capturing selfies with advanced features including face validation, liveness checks, and real-time feedback.
Features
- 🎯 Real-time Face Detection - Powered by Google ML Kit
- 🔒 Three Liveness Check Modes - Blink, mouth open, or both
- 📏 Advanced Face Validation - Size, orientation, eyes, and smile detection
- 🎨 Fully Customizable UI - Colors, messages, instructions, and themes
- ⚡ Instant Visual Feedback - Face overlay with corner brackets
- 🌐 Cross-platform - iOS 15.5+ and Android 21+
Quick Start
import 'package:smart_selfie_capture/smart_selfie_capture.dart';
SelfieCaptureScreen(
config: const SelfieConfig(
title: 'Take a Selfie',
enableLivenessCheck: true,
livenessCheckType: LivenessCheckType.mouthOpen,
),
onCaptureComplete: (SelfieResult result) {
print('Image saved: ${result.imagePath}');
print('Validated: ${result.isValidated}');
print('Liveness passed: ${result.livenessCheckPassed}');
},
)
Configuration
Use SelfieConfig to customize the capture behavior:
- Set SelfieConfig.validationRules for face validation criteria
- Enable liveness detection with SelfieConfig.enableLivenessCheck
- Choose liveness type: LivenessCheckType.blink, LivenessCheckType.mouthOpen, or LivenessCheckType.both
- Customize UI colors with SelfieConfig.primaryColor and SelfieConfig.backgroundColor
Validation Rules
Fine-tune face validation with ValidationRules:
- Face size constraints (ValidationRules.minFaceSize, ValidationRules.maxFaceSize)
- Head pose angles (ValidationRules.minEulerAngleX, ValidationRules.maxEulerAngleY, etc.)
- Feature detection (ValidationRules.requireEyesOpen, ValidationRules.requireSmile)
Result Handling
The SelfieResult object provides:
- SelfieResult.imagePath - Absolute path to the captured image
- SelfieResult.isValidated - Whether face validation passed
- SelfieResult.livenessCheckPassed - Whether liveness check passed
- SelfieResult.validationDetails - Detailed validation data
- SelfieResult.capturedAt - Timestamp of capture
Platform Requirements
- iOS: 15.5+
- Android: API 21+ (Android 5.0)
- Camera permissions must be granted before use
For detailed documentation, see:
- GitHub Repository
- API Reference in the package documentation
Classes
- SelfieCaptureScreen
- A screen that captures selfies with face validation and liveness checks.
- SelfieConfig
- Configuration for the selfie capture process.
- SelfieResult
- Result of a selfie capture operation.
- ValidationRules
- Rules for validating detected faces during selfie capture.
Enums
- LivenessCheckType
- Type of liveness check to perform.