A high-performance real-time Face Mask Detection system. Built with OpenCV YuNet, MobileNetV2 and a Threaded Architecture.
- Threaded Video Capture: Decouples camera I/O from AI processing.
- Batch Inference: Processes all faces in a frame simultaneously.
- Dual-Stream: 1280x720 (Display) + 640x360 (Inference).
- RGB Color Space: Correctly handles input channels.
- Smart Padding: Preserves face aspect ratio.
- YuNet Detector: Fast and accurate face detection.
- Resolution Independent: Elements scale dynamically to 720p, 1080p, or 4K.
- Modern Aesthetics: Rounded corners, floating floating pills, and semi-transparent dashboards.
├── models/ # AI Models (Auto-downloaded)
├── src/
│ ├── camera.py # Threaded Camera Engine
│ ├── config.py # Central Configuration & Environment
│ ├── detector.py # YuNet + MobileNetV2 Batch Logic
│ ├── ui.py # Clean Glass Rendering Engine
│ └── utils.py # Robust Model Loading
├── setup_env.py # One-click Setup Script
├── main.py # Application Entry Point
└── requirements.txt # Dependencies
-
Clone & Install:
pip install -r requirements.txt
-
Setup Environment: Automatically downloads SOTA models and sets up directories.
python setup_env.py
Run the main application:
python main.py- Q / ESC: Quit the application.
- "TensorFlow not found": Ensure
requirements.txtis installed. - "Camera Init Failed": Check if another app is using the webcam.
- Low FPS: The system is optimized for speed. If slow, check your CPU usage or lower
INFERENCE_WIDTHinsrc/config.py.
Based on the 'chandrikadeb7' reference architecture, enhanced with YuNet and Threaded I/O.