A comprehensive embedded face recognition system implementing real-time face detection and recognition on STM32N6570-DK development board using STEdgeAI.
- Real-time Face Detection using CenterFace neural network model
- Face Recognition with MobileFaceNet embeddings and cosine similarity
- Multi-face Tracking with embedding bank and similarity voting
- Hardware Acceleration via STM32N6 NPU (Neural Processing Unit)
- Live Camera Input with ISP processing pipeline
- PC Streaming Interface for remote monitoring and control
- LCD Display Output with face detection visualization
- Optimized Performance for embedded deployment
- STM32CubeIDE - Primary development environment
- STM32EdgeAI - Model conversion tool (stedgeai)
- STM32CubeProgrammer - Firmware flashing tool
- ARM GCC Toolchain - Cross-compilation toolchain (included in STM32CubeIDE)
-
Configure tool paths Edit stm32_tools_config.json and set the correct paths for your installation
-
Build Process
# Convert AI models ./scripts/compile_model.sh face_detection ./input_models/centerface.tflite ./scripts/compile_model.sh face_recognition ./input_models/mobilefacenet_int8_faces.onnx # Build in STM32CubeIDE, then sign and flash ./scripts/sign_binary.sh ./embedded/STM32CubeIDE/Debug/Project.bin ./scripts/flash_firmware.sh all
- STM32N6570-DK development board
- Camera Module (IMX335, VD55G1, or VD66GY supported)
- LCD Display (800x480 resolution)
- USB Connection for programming and debugging
- PC with STM32CubeIDE or ARM GCC toolchain
- STM32CubeIDE (recommended) or ARM GCC toolchain
- STM32CubeProgrammer for flashing
- STM32EdgeAI for model conversion
-
Configure and convert models:
# Configure tool paths in stm32_tools_config.json # Convert AI models ./scripts/compile_model.sh face_detection ./input_models/centerface.tflite ./scripts/compile_model.sh face_recognition ./input_models/mobilefacenet_int8_faces.onnx -
Build the embedded project:
# Using Makefile (from embedded directory) cd embedded && make clean && make -j$(nproc) # Or using STM32CubeIDE # Open embedded/STM32CubeIDE project, clean and rebuild -
Flash the complete system:
The STM32N6 requires flashing four separate components in this order:
# 1. Flash FSBL (First Stage Boot Loader) at 0x70000000 STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el MX66UW1G45G_STM32N6570-DK.stldr -w Binary/ai_fsbl.hex # 2. Flash Face Detection Model at 0x71000000 STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el MX66UW1G45G_STM32N6570-DK.stldr -w Binary/det_network_data.hex # 3. Flash Face Recognition Model at 0x72000000 STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el MX66UW1G45G_STM32N6570-DK.stldr -w Binary/rec_network_data.hex # 4. Flash signed application at 0x70100000 STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el MX66UW1G45G_STM32N6570-DK.stldr -w Binary/STM32N6_GettingStarted_ObjectDetection_signed.hexor use the provided flashing script!
Important Notes:
- Set BOOT1 switch to right position (dev mode) before flashing
- All .hex files are pre-built and available in the Binary/ directory
- The external loader MX66UW1G45G_STM32N6570-DK.stldr is required for external flash programming
- After flashing, set BOOT1 switch to left position (boot from flash) and power cycle
-
Connect and run:
- Connect camera module and LCD
- Power on the board
- System will start face detection automatically
- Face Detection: CenterFace model (128x128 input, INT8 quantized)
- Face Recognition: MobileFaceNet model (112x112 input, INT8 quantized)
- Image Processing: Hardware-accelerated cropping, resizing, format conversion
- Embedding Management: Multi-face tracking with similarity-based voting
- Communication: UART protocol for PC interface
- Architecture: CenterFace
- Input: 128x128 RGB
- Output: Face bounding boxes + keypoints
- Quantization: INT8
- Performance: ~9ms inference time
- Architecture: MobileFaceNet
- Input: 112x112 RGB aligned faces
- Output: 128-dimensional embeddings
- Quantization: INT8
- Performance: ~120ms inference time
The system supports PC connectivity for enhanced functionality:
- Live Video Stream from embedded system
- Face Recognition Results display
- Configuration Management
- Firmware Update capabilities
- Face Detection: ~17 FPS (including preprocessing)
- Face Recognition: ~5 FPS
- Power Consumption: ~0.25 W for the MCU only during full operation
- NPU Acceleration for neural network inference
- Multi-threading with hardware acceleration
- Memory Pool Management for efficient allocation
- Cache-optimized image processing algorithms
The codebase is designed for extensibility:
- Image Processing: Extend Src/crop_img.c
- AI Models: Add models to Models/ directory
- Communication: Modify Src/enhanced_pc_stream.c
- Display: Update Src/display_utils.c
Additional documentation available:
- Application Overview
- Boot Process
- Build Options
- Model Deployment
- Programming Guide - Complete flashing procedure
- Build Setup - Post-clone build instructions
- Coding Standards - Embedded C best practices
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create feature branch
- Install git hooks for code quality: ./install-git-hooks.sh
- Implement changes following coding standards
- Run quality checks: make check
- Write tests for new functionality
- Submit pull request
This project contains multiple license terms:
- Application code: See LICENSE
- STM32 components: ST proprietary license
- Third-party libraries: Various (see individual components)
- Issues: GitHub Issues
- Documentation: Project Wiki
- Community: Discussions
- STMicroelectronics for STM32N6 platform and STEdgeAI
- Original model authors (CenterFace, MobileFaceNet)
- Open source community contributors
Built for the embedded AI community
.png)



