A hybrid security system that locks/unlocks USB drives using face recognition.
This project combines:
- ☕ Java (GUI + USB Control)
- 🧠 Python (OpenCV Face Recognition)
- 📱 DroidCam (IP Camera)
- 🎥 Capture face dataset using phone camera (DroidCam)
- 🧠 Train face recognition model (LBPH)
- 👁️ Real-time face recognition
- 🔐 Automatically lock USB drives when inserted
- 🔓 Unlock USB only after successful face authentication
- 🖥️ Simple Swing GUI
- ⚡ Optimized for low-resource environments (CPU-only, no GPU required)
- Detect USB drives
- Lock USB automatically
- Launch Python scripts
- Read recognition result (
AUTHORIZED)
- Face dataset collection
- Model training (LBPH)
- Real-time recognition
pip install opencv-contrib-python
pip install pillow
pip install numpy- JDK 8+
- Swing
This project uses DroidCam as IP camera.
Example stream:
http://YOUR_IP:4747/video
Make sure:
- Phone and PC are on same network
- DroidCam is running
- URL works in browser
- Click Recon
- System captures ~30 images from camera
- Saves in:
dataset/
- Click Train
- Model saved in:
trainer/trainer.yml
-
When USB is inserted:
- Automatically detected
- Immediately locked (readonly)
- Click Disable Protection
- Python starts recognition
- If face is valid:
AUTHORIZED
- Java reads
AUTHORIZED - Executes unlock script
- USB becomes accessible
- LBPH algorithm for efficient face recognition
- CPU-only execution (no GPU required)
- Java ↔ Python communication via process output
- Real-time USB monitoring
⚠️ This project was built and tested on a very low-end machine:
- CPU: Intel Core 2 Quad Q8300 @ 2.5GHz
- RAM: 4GB
- GPU: None (CPU-only, no VRAM)
✔️ Despite that, system runs successfully
-
Requires Administrator privileges (for
diskpart) -
Works best with:
- Good lighting
- Stable camera connection
-
USB locking uses
.batscripts + PowerShell
- Multi-user recognition
- Auto-lock when face disappears
- Better UI feedback
- Remove
.bat→ direct Java control - Logging system
ATEF Aliat


