Skip to content

About

Real-time AI system that detects University of Sindh student ID cards via live camera (Webcam/Phone) using MobileNetV2 transfer learning + OpenCV. Built with TensorFlow, Tkinter desktop GUI. 97-98% confidence on target cards on target cards.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

🎓 University of Sindh — AI-Based ID Card Detection System

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.


📌 Project Overview

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.


✨ Features

  • 🔴 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

🗂️ Project Structure

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)

🧠 Model Architecture

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

Data Augmentation Applied

  • Rotation (±20°)
  • Width/Height shift (10%)
  • Zoom (15%)
  • Brightness jitter (0.7–1.3)
  • Shear (10%)

📦 Dataset

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).


🚀 Getting Started

Prerequisites

  • Python 3.10+
  • Windows 10/11
  • DroidCam app on Android phone (for phone camera)

Installation

# 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

Running the App

  1. Open DroidCam app on your phone (keep desktop client closed)
  2. Run the application:
python app.py
  1. Click ▶ Start Camera in the GUI
  2. Hold a University of Sindh ID card in front of the camera

If the camera doesn't start, change CAMERA_INDEX = 1 to CAMERA_INDEX = 0 at the top of app.py


⚙️ Configuration

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)

🏋️ Training Your Own Model

The training notebook is available on Kaggle. To retrain:

  1. Organize your dataset:
Cards Data/
├── my_uni/       ← your university card images
└── other_uni/    ← negative class images
  1. Upload to Kaggle as a dataset named cards-data
  2. Run the training notebook (GPU T4 recommended)
  3. Download university_id_classifier.keras from outputs
  4. Place in model/ folder

🔍 How It Works

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

🛠️ Tech Stack

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

📋 Requirements

tensorflow==2.19.0
opencv-python==4.11.0.86
Pillow==11.2.1
numpy==2.1.3

⚠️ Limitations

  • 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

🔮 Future Improvements

  • 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 .exe with PyInstaller

👨‍💻 Author

Muhammad Haroon Abbas BS Computer Science — University of Sindh, Laar Campus @ Badin Roll No: 2K23/BLCS/38


📄 License

This project is for academic/educational purposes only. Not intended for production security use.

About

Real-time AI system that detects University of Sindh student ID cards via live camera (Webcam/Phone) using MobileNetV2 transfer learning + OpenCV. Built with TensorFlow, Tkinter desktop GUI. 97-98% confidence on target cards on target cards.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages