This document provides a deep dive into the system's architecture, API specifications, and development guidelines.
# services/face_embed_api/app.py
# Supports multiple worker processes
WORKERS=4 # Adjust based on Hailo device performance
# Asynchronous processing
async def extract_embedding(...)// Batch processing configuration
BATCH_SIZE=3 // Batch size
MAX_WAIT_TIME=100 // Maximum wait time (ms)
API_TIMEOUT=5000 // API timeout (ms)- Single Device Latency: < 40ms (FaceEmbed API)
- End-to-End Latency: < 300ms (Full pipeline)
- Concurrent Processing: 20+ devices simultaneously
- Throughput: 5fps/device
Due to the limitation that Hailo-8 hardware can only load and run one AI model at a time, the API has been refactored into an all-in-one interface to simplify calls and optimize performance.
This endpoint is the recommended method for the standard workflow. It performs face detection, landmark localization, face alignment, and feature vector extraction in a single API call.
POST http://192.168.10.179:8000/detect_and_embed
Content-Type: application/json
{
"image_base64": "base64_encoded_image"
}Response Example (one face detected):
[
{
"bbox": [100, 100, 200, 200],
"landmarks": [
[120, 120], [180, 120], [150, 150], [130, 180], [170, 180]
],
"embedding": [0.123, -0.456, ..., 0.789]
}
]If no faces are detected, it returns an empty list [].
These endpoints are for advanced scenarios, such as when you have already obtained the bounding box and landmarks through other means.
POST http://192.168.10.179:8000/embed
Content-Type: application/json
{
"image_base64": "base64_encoded_image",
"bbox": {"x": 100, "y": 100, "w": 200, "h": 200},
"landmarks": [
{"x": 120, "y": 120},
{"x": 180, "y": 120},
{"x": 150, "y": 150},
{"x": 130, "y": 180},
{"x": 170, "y": 180}
]
}POST http://192.168.10.179:8000/batch_embed
Content-Type: application/json
{
"images": [
{
"image_base64": "...",
"bbox": {"x": 100, "y": 100, "w": 200, "h": 200}
}
]
}Topic: vision/frames/grove_vision_ai_v2_001
{
"ts": "2025-06-05T16:30:00Z",
"img_b64": "base64_image_data"
}Note: This is the standardized format after being processed by Node-RED. For details, see the Data Flow Documentation.
Topic: access/result/grove_vision_ai_v2_001
{
"ts": "2025-06-05T16:30:00Z",
"device_id": "grove_vision_ai_v2_001",
"decision": true,
"name": "John Doe",
"distance": 0.28,
"confidence": 0.95,
"processing_time_ms": 280,
"matched_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
}Topic: access/enroll/{device_id}
{
"name": "Jane Smith",
"action": "start",
"collection": "office_entrance"
}face_rec_r2000/
βββ services/ # Core services
β βββ face_embed_api/ # β
Hailo-8 Face Embedding API (Validated, Deployed Standalone)
β β βββ src/ # Source code directory
β β β βββ face_embed_api/
β β β βββ app.py # FastAPI Application (Concurrency supported)
β β β βββ utils.py # Hailo Async Inference Engine
β β βββ tests/ # Complete test suite (28 tests, 100% pass)
β β βββ scripts/ # Start and test scripts
β β βββ models/ # AI model files (arcface_mobilefacenet.hef, scrfd_10g.hef)
β β βββ docs/ # API documentation and test reports
β βββ qdrant/ # Vector database configuration (Main Server)
β βββ mqtt/ # MQTT configuration (Main Server)
β βββ node_red/ # Node-RED data and configuration
β βββ data/ # Node-RED runtime data
β βββ face_access_control.json # Face recognition flow configuration
βββ deployment/ # Deployment scripts
β βββ start_services.sh # Distributed deployment script (Main Server)
βββ tests/ # Integration test code
βββ docs/ # Deployment documentation
βββ docker-compose.yml # Main Server service orchestration (Qdrant + MQTT + Node-RED)
Key Notes:
- β FaceEmbed API: Hardware integration is complete and verified, running on a dedicated Hailo device.
- π³ Docker Services: Only includes main server components, not AI services requiring direct hardware access.
- π Distributed Architecture: A field-proven cross-machine deployment model.
- βοΈ Centralized Configuration: All parameters are managed within a single Node-RED node, eliminating the need for
.envfiles.
The latest version of this system uses a radically simplified configuration method. All addresses and critical parameters for external dependencies (Hailo API, Qdrant DB) are managed centrally within a single Node-RED node. There is no need to handle .env files or modify Docker Compose variables.
- After starting services, access Node-RED:
http://<main-server-ip>:1880 - Find the
[Global Config (Load on Start)]node, located in the top-left corner of the "Face Access Control" flow. - Double-click the node to edit all configurations, then click "Deploy" to apply changes.
// Example from inside the [Global Config (Load on Start)] node
// Qdrant Vector Database Configuration
flow.set('qdrant_host', 'localhost');
flow.set('qdrant_port', '6333');
flow.set('qdrant_api_key', 'face_access_2025');
// Hailo AI Chip (Face Vector API) Configuration
flow.set('hailo_host', '192.168.10.179');
flow.set('hailo_port', '8000');
// Grove Vision AI Camera Configuration
flow.set('image_width', 480);
flow.set('image_height', 480);- FaceEmbed API Connection Failed
# Check Hailo device network connectivity
ping 192.168.10.179
# Check API service status
curl http://192.168.10.179:8000/health- Insufficient Concurrent Performance
# Adjust the number of workers
export FACE_EMBED_API_WORKERS=8
# Optimize batch processing
export BATCH_SIZE=5- Node-RED Flow Errors
# View Node-RED logs
docker-compose logs -f node-red
# Check environment variable configurations- Network Isolation: Deployed on a local area network with no external internet dependency.
- API Authentication: Supports API Key validation.
- Data Encryption: Supports HTTPS/TLS for data in transit.
- Privacy Protection: Stores only vector embeddings, not original images.
- Distributed Architecture Design
- FaceEmbed API Concurrency Optimization
- Cross-Machine Calls in Node-RED
- Docker Containerization (Main Server)
- Batch Processing Optimization
- System Simplification and Centralized Configuration
- Deployment Scripts and Documentation
- β Full English Documentation and Code Comments (All user-facing docs translated)
- β Hailo-8 Hardware Integration Validation (28 tests passed, 3-18ms inference)
- β FaceEmbed API Production Deployment (Async inference, 512-dim vectors)
- β Cross-Network API Call Validation (Node-RED β Hailo Device)
- Grove Vision AI V2 Full Integration Test
- End-to-End Distributed Flow Validation
- Multi-Device Concurrent Performance Test
- Fork the project
- Create a feature branch (
git checkout -b feature/distributed-deployment) - Commit your changes (
git commit -m 'Add distributed deployment support') - Push to the branch (
git push origin feature/distributed-deployment) - Create a Pull Request
- π Data Flow and Formats: Detailed documentation on data flow and formats between modules.
- π See the Deployment Guide
- π Create an Issue
- π¬ Join the technical discussion
- π§ Concurrency configuration tuning
- π Monitoring metric analysis
- β‘ Latency optimization suggestions
- π₯οΈ Main server configuration recommendations
- π Hailo device selection
- π‘ Network environment requirements
Note: This project is optimized for distributed deployment and supports concurrent processing from multiple devices. It is recommended to carefully read the Deployment Guide before deployment.