A complete, production-ready React Native facial recognition application using the state-of-the-art ArcFace ONNX model. Features face registration, real-time verification, and secure local storage of biometric data.
- Face Registration: Capture and register faces with names
- Face Verification: Real-time comparison against registered faces
- Face Recognition: Identify faces from the camera feed
- Persistent Storage: Local storage using AsyncStorage (privacy-first)
- ArcFace ONNX Model: State-of-the-art face recognition with 512-dimensional embeddings
- Real-time Processing: Live face detection and analysis
- High Accuracy: Cosine similarity matching with configurable thresholds
- On-device Processing: All AI processing happens locally for privacy
- Intuitive Navigation: Clean home screen with clear options
- Real-time Feedback: Live face positioning guidance
- Visual Indicators: Color-coded borders (green=match, red=no match, orange=positioning)
- Empty States: Helpful guidance for first-time users
- Error Handling: Graceful error recovery and user feedback
- Local-only Storage: Face data never leaves the device
- No Cloud Dependencies: Completely offline operation
- Secure Embeddings: Mathematical representations, not actual photos
- Permission Handling: Proper camera permission management
- Node.js >= 18.0.0
- npm >= 8.0.0
- Expo CLI:
npm install -g @expo/cli - iOS Simulator or Android Emulator (or physical device)
-
Clone the repository
git clone https://github.com/maateusx/react-native-facial-recognition.git cd react-native-facial-recognition -
Install dependencies
npm install
-
Start the development server
npm start
-
Run on your preferred platform
# iOS Simulator npm run ios # Android Emulator npm run android # Web Browser npm run web
- Tap "π€ Register Face" on the home screen
- Position your face in the camera frame
- Wait for the green border (face properly positioned)
- Tap "π· Capture Face" when ready
- Review the captured photo
- Enter your name and tap "Complete Registration"
- Tap "π Verify Face" on the home screen
- Select a registered face from the list
- Tap "Start Verification"
- Position your face in the camera frame
- The app will automatically verify your identity
- See real-time results with confidence percentage
- Tap "π· Open Camera" on the home screen
- Point camera at any face
- The app will attempt to recognize registered faces
- See real-time face detection and analysis
src/
βββ screens/ # App screens
β βββ App.tsx # Main navigation
β βββ camera.tsx # General face recognition
β βββ face-registration.tsx
β βββ face-selection.tsx
β βββ face-verification.tsx
βββ services/ # Business logic
β βββ faceStorage.ts
βββ assets/ # Static assets
βββ models/ # ONNX model files
- Frontend: React Native + Expo
- Language: TypeScript
- AI/ML: ONNX Runtime + ArcFace model
- Computer Vision: react-native-vision-camera
- Storage: AsyncStorage
- Animations: React Native Reanimated
- Handles CRUD operations for registered faces
- AsyncStorage persistence
- Face data validation and management
- ONNX model loading and inference
- 512-dimensional face embeddings
- Cosine similarity matching
- Tensor memory management
Adjust the similarity threshold in face-verification.tsx:
const threshold = 0.6; // 60% similarity requiredConfigure face detection options in any camera screen:
const faceDetectionOptions = {
performanceMode: 'accurate',
landmarkMode: 'all',
classificationMode: 'all',
// ... other options
};The ArcFace model expects:
- Input: 112Γ112Γ3 images, normalized to [-1, 1]
- Output: 512-dimensional embedding vectors
- Format: ONNX (CPU execution)
- Face Detection: ~30 FPS (device dependent)
- Embedding Generation: ~100-300ms per face
- Face Verification: ~400-500ms total
- Model Size: ~23MB (ArcFace ONNX)
- Memory Usage: ~50-100MB during processing
π Want to generate your own benchmark data?
Check out our comprehensive BENCHMARKING.md guide to learn how to:
- Measure real performance on your devices
- Use the built-in benchmark tools
- Collect and analyze performance metrics
- Generate README-ready benchmark data
- Use device GPU acceleration when available
- Implement face detection throttling for battery efficiency
- Cache model loading for faster subsequent operations
- Optimize image preprocessing pipeline
# Development
npm start # Start Expo dev server
npm run dev # Start with dev client
npm run clean # Clean cache and reinstall
# Platform-specific
npm run ios # Run on iOS
npm run android # Run on Android
npm run web # Run on web
# Code Quality
npm run lint # ESLint
npm run type-check # TypeScript check
npm test # Jest tests
# Performance Testing
# See BENCHMARKING.md for detailed instructions
# Built-in performance monitoring available in-app
# Build
npm run build # Development build
npm run prebuild # Expo prebuild- New Screen: Add to
src/screens/and update navigation inApp.tsx - Face Storage: Extend
faceStorage.tsservice - AI Models: Add new ONNX models to
assets/models/ - Styling: Follow existing StyleSheet patterns
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit with clear messages:
git commit -m 'Add amazing feature' - Push to your fork:
git push origin feature/amazing-feature - Open a Pull Request
- Use TypeScript for all new code
- Follow ESLint configuration
- Add proper error handling
- Include JSDoc comments for public APIs
- Write tests for new features
- iOS Simulator: Face detection may not work on simulator (use physical device)
- Android Permissions: Ensure camera permissions are granted
- Model Loading: First-time model load may take longer
- Memory Management: Large face databases may require optimization
This project is licensed under the MIT License - see the LICENSE file for details.
- Yosuke Hanaoka (@yoshan0921): Special thanks for the excellent face detection tutorial that provided foundational guidance for implementing React Native + Expo face detection
- ArcFace: Face recognition model by Deng et al.
- ONNX Runtime: Cross-platform ML inference
- React Native Vision Camera: Camera functionality and face detection
- Expo: Development platform and tools
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ by Mateus
If this project helped you, please consider giving it a β on GitHub!