KRS Door Automation is an Edge-AI powered door security system combining:
- Face Recognition (Dlib)
- Anti-Spoofing / Liveness Detection (SilentFace)
- ToF-based Human Detection (VL53L0X)
- High-performance GPIO hardware control (libgpiod + C++)
- Dockerized runtime (CPU, GPU, Raspberry Pi modes)
Built for maximum speed, reliability, and security on resource-limited devices like Raspberry Pi.
- Introduction
- Multithreading & Parallel Processing Architecture
- Key Features
- Tech Stack
- Installation
- Deployment
- Directory Structure
- Usage Overview
- Hardware Requirements
- Electronics & Power Architecture
- API Reference
- Security Notes
- Future Roadmap
Modern access-control systems demand speed, accuracy, and spoof-proof verification.
KRS Door Automation delivers this by combining:
- Deep-learning face recognition
- SilentFace anti-spoofing (MiniFASNet)
- ToF sensor for human presence detection
- Optimized multi-thread processing
- Real-time C++ hardware controller
Suitable for:
✔ Research Labs ✔ Corporate Offices ✔ Hostels & Residential Buildings ✔ Industrial & IoT Security
/live/start launches a separate ML process, preventing the API from freezing:
live_process = multiprocessing.Process(target=live_worker)- API always stays responsive
- ML cannot block or overload the server
- Raspberry Pi stays cool and smooth
Inside the ML worker:
class FrameProcessor(Thread):
def run():
# Anti-spoof + RecognitionRuns asynchronously:
- Reads frames
- Anti-spoofing
- Face recognition
- Sends results to shared dictionary
ThreadPoolExecutor(max_workers=4)SilentFace loads multiple MiniFASNet models and evaluates them in parallel → doubling performance.
Your C++ controller runs FOUR independent threads:
| Thread | Purpose |
|---|---|
| Heartbeat Thread | Checks /heartbeat every 5s |
| Sensor Thread | Reads ToF sensor every 50ms |
| Live Controller Thread | Starts/stops ML when needed |
| Polling Thread | Reads /live/status for final decision |
🔥 ML runs only when someone approaches the door → huge CPU savings.
- Dlib model
- Fast encoding matching
- Supports multi-image encodings
- Multi-model MiniFASNet
- Prevents photo, screen replay, and printed images
- ToF sensing (VL53L0X)
- MOSFET-driven solenoid lock
- GPIO status LEDs
- Real-time control in C++
Modes:
- cpu
- gpu
- pi
| Layer | Technology |
|---|---|
| API | FastAPI |
| Face Recognition | Dlib |
| Anti-Spoofing | SilentFace (MiniFASNet) |
| Hardware | C++ + libgpiod |
| Parallel ML | multiprocessing + threading + ThreadPoolExecutor |
| Build | CMake |
| Deployment | Docker + Docker Compose |
sudo apt update
sudo apt install -y git python3 python3-venv cmake docker docker-composegit clone https://github.com/KIIT-Robotic-Society/Door-Automation.git
cd Door-Automation
sudo bash launch_docker.sh cpu # or gpu / pi
sudo bash launch.sh.
├── app.py
├── CMakeLists.txt
├── dlib_face_recognition_resnet_model_v1.dat.bz2
├── docker-compose.yaml
├── dockerfile
├── encodings.pickle
├── include
│ ├── I2Cdev.cpp
│ ├── I2Cdev.hpp
│ ├── json_fwd.hpp
│ ├── json.hpp
│ ├── single.cpp
│ ├── single.hpp
│ ├── VL53L0X.cpp
│ ├── VL53L0X_defines.hpp
│ └── VL53L0X.hpp
├── launch_docker.sh
├── launch.sh
├── modelinit.ipynb
├── server.py
├── SilentFaceAntiSpoofing
│ ├── datasets
│ ├── images
│ ├── resources
│ ├── src
│ └── requirements.txt
└── src
└── main.cpp
Here is the README-formatted, polished, and professional Usage Overview section—ready to paste directly into your README.md:
The system operates in the following sequence:
- Monitor environment using the ToF distance sensor
- If no person is detected → system stays in IDLE mode
- If a person enters range → ML pipeline is automatically activated
-
Start AI recognition (
/live/start)- Raspberry Pi GPIO 22 = ML Active LED ON
- Python ML worker begins running in a separate process
- C++ hardware controller switches to active monitoring state
-
Camera captures frames only during ML mode
- Reduces CPU load
- Prevents thermal throttling
- Extends hardware life
-
Run face detection + recognition
- RetinaFace detects the face
- Dlib computes face embeddings
- Matches known users from
encodings.pickle
-
Run SilentFace anti-spoofing
- Multiple MiniFASNet models run in parallel
- Prevents printed-photo, replay video, and phone screen spoof attacks
- Unlock door (GPIO17 = HIGH)
- Wait for the configured unlock duration
- Lock door (GPIO17 = LOW)
- Log the event with a timestamp in
system.log - Stop ML pipeline and return to idle mode
- ML pipeline automatically stops (
/live/stop) - GPIO22 (ML Active) turns OFF
- GPIO27 (Idle LED) turns ON
- System returns to low-power IDLE mode
- Raspberry Pi 4
- VL53L0X
- USB Camera
- 12V Solenoid Lock
- D418 MOSFET Module
- PCBs (Power, Fan, Lock, LEDs)
| GPIO Pin | Function |
|---|---|
| 17 | Door Lock Trigger |
| 27 | System Idle LED |
| 22 | ML Active LED |
{"status": "live"}Starts ML process.
Stops ML process.
Returns:
{
"status": "running",
"name": "user",
"label": 1
}- All AI runs locally
- No cloud storage
- Encodings stored offline
- Anti-spoofing blocks photo/video attacks
- Docker sandboxing protects system
- Web dashboard
- RFID/NFC + Face MFA
- BLE Token Authentication
- YOLO-based liveness
- Cloud analytics
- Multi-door deployment