Skip to content

Egyptian ID Card Detection, Alignment and Text Segments Extraction

Notifications You must be signed in to change notification settings

KarimIbrahim11/ID-Card-Detection

Repository files navigation

ID Card Detection

Egyptian National ID Card Detection, Alignment and Text Region Extractions.

Assumptions:

Assumption 1:

This solution assumes the ID is scanned.

Assumption 2:

This solution assumes the detection of the front side only of the ID.

Demo:

Input image as follows:

test

The script will first detect the SIFT features and match them between the following template and the test image:

sift_template

If Matches Found:

Figure_1

A homography matrix between the image and the template is found. If the image moves out of frame, the matrix is compensated by another translation matrix to accomodate the translation back in to frame. The result of the translation is as follows:

Warped

After warping, Canny Edges are applied for edge detection and finding the largest contour to only select the card from the scene. The largest contour is then warped to a fixed size of (672, 448). This is a static size I configured best for the application.

cropped_card

The card is then converted to binary, dilated and eroded for blob detection by finding contours around blobs. The blobs will resemble the text regions and the face. We need to disregard the face Bounding Box. I used dlib's face detector to find the region of the face and delete any of the boxes that overlap with the region of the face. The final result is as follows:

test

The bounding boxes of the text are saved in output/ directory

To Duplicate Results:

Add yout images to the test-dataset directory and write the following commands

git clone https://github.com/KarimIbrahim11/ID-Card-Detection.git
cd ID-Card-Detection
conda env create -f env.yaml
conda activate env
python id_detector.py

About

Egyptian ID Card Detection, Alignment and Text Segments Extraction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages