Real-time blink detection system using a Raspberry Pi Zero 2W, Camera v3 (IMX708), TFLite, and MQTT.
- Real-time eye blink detection using a TFLite model with Haar Cascade face/eye detection
- MQTT publishing of blink counts at configurable intervals with auto-reconnect
- Web-based configuration portal (Flask) for Wi-Fi, MQTT, camera, and model settings
- Automatic AP hotspot mode when Wi-Fi is unavailable (accessible at
192.168.4.1:5000) - Dual-stream Picamera2 pipeline: low-res YUV for fast inference, optional high-res for preview
- Optimized for Pi Zero 2W: minimal CPU/RAM usage in headless mode
- Copy this folder to your Raspberry Pi Zero 2W
- Run the setup script:
cd /path/to/blink-counter sudo bash setup.sh - Reboot:
sudo reboot
- The app starts automatically. Configure via the web portal at
http://<pi-ip>:5000
| File | Description |
|---|---|
TFlite_tester_Copy.py |
Main application script |
eye_state_model2.tflite |
TFLite eye-state classification model |
rpi_config.json |
Runtime configuration (Wi-Fi, MQTT, camera, thresholds) |
setup.sh |
One-command installer for all dependencies |
blink_app |
Bash launcher script (handles venv + root) |
check_flask_ap.sh |
Diagnostic script for Flask/AP networking |
autostart/ |
Desktop autostart entries |
Access the web portal at http://<pi-ip>:5000 to configure:
- Wi-Fi: SSID and password
- MQTT: Server, port, credentials, publish interval
- Camera: Resolution, FPS, preview toggle
- Model: Blink thresholds, detection stride, TFLite threads
All installed automatically by setup.sh:
python3-picamera2,libcamera-appspython3-opencvpython3-flaskpaho-mqtttflite-runtime(from piwheels)
- Raspberry Pi Zero 2W
- Raspberry Pi Camera Module v3 (IMX708)
MIT