A real-time AI system that analyzes student ID cards via live camera feed and verifies whether the card belongs to the University of Sindh, Jamshoro.
This project is an end-to-end deep learning application built for academic exhibition. It uses a fine-tuned MobileNetV2 model trained via transfer learning to perform binary classification on student ID card images — distinguishing University of Sindh cards from all others. The system runs in real-time using a phone camera connected via DroidCam, with results displayed in a clean desktop GUI.
- 🔴 Live Camera Detection — Real-time ID card scanning using phone camera (DroidCam)
- 🧠 Transfer Learning Model — MobileNetV2 fine-tuned on custom dataset (97–98% confidence on target cards)
- 🃏 Automatic Card Detection — OpenCV contour detection isolates the card region from the background
- ✅ Instant Verdict — VERIFIED or REJECTED with confidence score displayed live
- 🖥️ Desktop GUI — Built with Tkinter, dark-themed UI with animated confidence bar
- 📦 Lightweight — Runs fully locally, no internet required at inference time
ID Card Detection System/
├── app.py # Main desktop application
├── logo_template.jpeg # University of Sindh logo crop (for template matching)
├── requirements.txt # Python dependencies
├── model/
│ └── university_id_classifier.keras # Trained MobileNetV2 model
└── Cards Data/ # Training dataset (not included in repo)
├── my_uni/ # University of Sindh card images (~308)
└── other_uni/ # Other/CNIC card images (~308)
| Component | Details |
|---|---|
| Base Model | MobileNetV2 (ImageNet pre-trained) |
| Training Strategy | Two-phase: frozen base → fine-tune last 30 layers |
| Input Size | 224 × 224 × 3 |
| Output | Binary (sigmoid) — my_uni vs other_uni |
| Optimizer | Adam (Phase 1: 1e-3, Phase 2: 1e-5) |
| Regularization | Dropout (0.4, 0.3), BatchNormalization |
| Trained On | Kaggle (GPU T4) |
| Val Accuracy | 100% on held-out validation set |
- Rotation (±20°)
- Width/Height shift (10%)
- Zoom (15%)
- Brightness jitter (0.7–1.3)
- Shear (10%)
| Class | Source | Count |
|---|---|---|
my_uni |
Real photos of University of Sindh student ID cards (self-collected) | ~308 |
other_uni |
Pakistani CNIC cards from Roboflow CNIC Dataset | 308 |
Note: Dataset is not included in this repository due to privacy concerns (real student ID cards).
- Python 3.10+
- Windows 10/11
- DroidCam app on Android phone (for phone camera)
# Clone the repository
git clone https://github.com/yourusername/id-card-detection-system.git
cd id-card-detection-system
# Install dependencies
pip install -r requirements.txt- Open DroidCam app on your phone (keep desktop client closed)
- Run the application:
python app.py- Click ▶ Start Camera in the GUI
- Hold a University of Sindh ID card in front of the camera
If the camera doesn't start, change
CAMERA_INDEX = 1toCAMERA_INDEX = 0at the top ofapp.py
All settings are at the top of app.py:
MODEL_PATH = "model/university_id_classifier.keras"
LOGO_PATH = "logo_template.jpeg"
IMG_SIZE = (224, 224)
CONF_THRESHOLD = 0.90 # Minimum confidence to mark as VERIFIED
CAMERA_INDEX = 1 # Camera index (1 = DroidCam, 0 = laptop webcam)The training notebook is available on Kaggle. To retrain:
- Organize your dataset:
Cards Data/
├── my_uni/ ← your university card images
└── other_uni/ ← negative class images
- Upload to Kaggle as a dataset named
cards-data - Run the training notebook (GPU T4 recommended)
- Download
university_id_classifier.kerasfrom outputs - Place in
model/folder
Phone Camera (DroidCam)
↓
OpenCV reads frame
↓
Card region detected via contour analysis
↓
Region preprocessed → 224×224, normalized
↓
MobileNetV2 predicts confidence score
↓
Confidence ≥ 90% → ✅ VERIFIED
Confidence < 90% → ❌ REJECTED
↓
Result displayed in Tkinter GUI with bounding box on video feed
| Layer | Technology |
|---|---|
| Deep Learning | TensorFlow / Keras |
| Base Model | MobileNetV2 (transfer learning) |
| Computer Vision | OpenCV |
| GUI | Tkinter + Pillow |
| Training Platform | Kaggle (GPU T4) |
| Camera | DroidCam (Android → Windows) |
| Language | Python 3.10 |
tensorflow==2.19.0
opencv-python==4.11.0.86
Pillow==11.2.1
numpy==2.1.3
- Trained on a small dataset (~308 images per class) — performance may vary on cards from other universities with similar color schemes
- Negative class consists only of Pakistani CNIC cards — a card from another university with a similar blue design might score higher than expected
- Requires good lighting and a reasonably straight card angle for best results
- DroidCam must be running on phone before launching the app
- Add OCR module (EasyOCR) to verify university name text as a second layer
- Re-introduce logo template matching with a higher-quality logo crop
- Expand negative class with more university card varieties
- Add student face matching against photo on card
- Package as standalone
.exewith PyInstaller
Muhammad Haroon Abbas BS Computer Science — University of Sindh, Laar Campus @ Badin Roll No: 2K23/BLCS/38
This project is for academic/educational purposes only. Not intended for production security use.