How alexisharara/raspberrypiefacialrecognition works
This Raspberry Pi treasure box uses face recognition to decide whether to unlock a physical latch. The main workflow is a button press, image capture, face detection and normalization, model prediction, then a hardware lock action. Separate scripts collect positive samples and train the recognizer from positive and negative images. The README is brief; the sampled source shows the Pi-camera path and documents a webcam alternative. Edges reflect visible calls and reads/writes; optional webcam wiring is documented in config.py rather than verified at runtime.
Main entry points: config.py Runtime configuration · box.py Lock controller · train.py Model trainer · hardware.py Button and servo
Components 15
Box control
- Lock controller
box.py - Runtime configuration
config.py
Face recognition
- Face detection and crop
face.py - Eigenface recognizer
Capture and hardware
- Pi camera capture
picam.py - USB webcam capture
webcam.py - Button and servo
hardware.py
Training data
- Positive image capture
capture-positives.py - USB positive capture
capture-positives_usbcam.py - Positive face images
training - Negative face images
training/negative - Model trainer
train.py - Saved model file
Other components
- User
- GPIO and servo hardware
Connections 22
- User → Button and servo: presses button
hardware.py - Lock controller → Runtime configuration: loads settings
box.py - Lock controller → Button and servo: checks and actuates
box.py - Lock controller → Eigenface recognizer: loads and predicts
box.py - Lock controller → Face detection and crop: detects and crops
box.py - Runtime configuration → Pi camera capture: creates camera
config.py - Runtime configuration → USB webcam capture: selects alternative
config.py - Button and servo → GPIO and servo hardware: reads and drives
hardware.py - Positive image capture → Runtime configuration: gets settings
capture-positives.py - Positive image capture → Button and servo: checks button
capture-positives.py - Positive image capture → Face detection and crop: detects and crops
capture-positives.py - Positive image capture → Positive face images: writes images
capture-positives.py - USB positive capture → Runtime configuration: gets settings
capture-positives_usbcam.py - USB positive capture → Button and servo: checks button
capture-positives_usbcam.py - USB positive capture → Face detection and crop: detects and crops
capture-positives_usbcam.py - USB positive capture → Positive face images: writes images
capture-positives_usbcam.py - Model trainer → Runtime configuration: reads settings
train.py - Model trainer → Face detection and crop: resizes images
train.py - Model trainer → Positive face images: reads images
train.py - Model trainer → Negative face images: reads images
train.py - Model trainer → Saved model file: saves model
train.py - Lock controller → Saved model file: loads model
box.py