afrozchakure / Aadhar-OCR

This is a repository for Aadhar OCR 💳
GNU General Public License v3.0
6 stars 2 forks source link

ID Recognition

GitHub stars GitHub license GitHub forks Visits Badge Created Badge Updated Badge

Structure and Usage -

Directories:

test_images -
    which contains testing images.
result - 
    it contains JSON object file which contains extracted information.
model - 
    it contains our Faster RCNN model for detecting card images.

Files:

id_card_detail_extract.py - 
    the file will detect the card from the image, crop it and perform required text extraction from the image and save the output in ``result`` folder in JSON format.
id_card_detection_camera.py - 
    this file can be used to detect card in a live video stream through from a primary camera source.

Working with the model:

How to Run:

Tested on Python 3.6.9

Requirements:
  1. To install the requirements.
    pip install -r requirements.txt

  2. Runs the application with the default webcam. (To detect ID card in live video stream)
    python3 id_card_detection_camera.py

  3. Runs the application with the image file. Default image file "test_images/image1.jpg".
    python3 id_card_detail_extract.py

Steps/ Working Flow:

  1. First, our Faster RCNN model tries to Identity Regions of Interest (ROI) containing the required information with deep learning.
  2. If a card is detected it creates a bounding box around it and crops that part of the image.
  3. That cropped image is then fed into our OpenCV and pytesseract model where we perform text extraction.
  4. Our model extracts information such as Name, Gender, Mobile No, UID and Aadhar no. from the image.
  5. The Extracted information is then printed and fed into a JSON file, where it is saved.

Use Case:

Sample ID Cards:

Model Accuracy and Performace:

  1. The accuracy of our model mostly depends on the quality of the image as well as the orientation.
  2. The Faster RCNN model is able to achieve accuracy of more than 90% for detecting a card in the image.
  3. For extracting Text from the Image the model needs to be customized as per the nature of different cards like Aadhar Card, Driving License, Pan Card, etc.

For Aadhar Card Images the performance measures are:

  1. Time: 6.92 seconds
  2. Ram Usage: 0.74 GB
  3. CPU Usage: Around 55K of event cycles
Task Time Ram Usage
Text detection with faster RCNN 5.97 seconds 0.74 GB
Cropping the image (And if not displaying the cropped image) 0.09 seconds 0.74 GB
Extracting text with OCR and saving in JSON 0.08 seconds 0.74 GB
Total time taken by Entire code 6.92 seconds 0.74 GB

(The above steps were implemented for extracting Information from Aadhar Card and the model works well for it)

Future Steps: