Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active February 11, 2021 09:53
Show Gist options
  • Save symisc/98acade7951db381fa781db0f7b95389 to your computer and use it in GitHub Desktop.
Save symisc/98acade7951db381fa781db0f7b95389 to your computer and use it in GitHub Desktop.
Scan a government issued ID card from India/Malaysia/Singapore and others via the PixLab docscan API endpoint. Extract the user face and process all fields - https://pixlab.io/cmd?id=docscan
import requests
import json
# Given a government issued ID card from India (Aadhaar), Malaysia, Singapore, etc., extract the user face and parse all fields.
#
# PixLab recommend that you connect your AWS S3 bucket via your dashboard at https://pixlab.io/dashboard
# so that any cropped face or MRZ crop is stored automatically on your S3 bucket rather than the PixLab one.
# This feature should give you full control over your analyzed media files.
#
# https://pixlab.io/cmd?id=docscan for additional information.
req = requests.get('https://api.pixlab.io/docscan',params={
'img':'https://currenthunt.com/wp-content/uploads/2019/07/Aadhaar-Card-min.jpg', # Aadhaar ID Card sample
'type':'idcard', # We are expecting an ID card
'country': 'india', # from India, we support also Malaysia/Singapore/US and Passports,
'key':'PIXLAB_API_KEY' # https://pixlab.io/dashboard
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print ("User Cropped Face: " + reply['face_url'])
# print ("Scanned Text: " + reply['full_text'])
print ("Fields: ")
# Display all scanned fields
if "country" in reply['fields']:
print ("\tIssuing Country: " + reply['fields']['country'])
if "id" in reply['fields']:
print ("\tID number: " + reply['fields']['id'])
if "name" in reply['fields']:
print ("\tName: " + reply['fields']['name'])
if "address" in reply['fields']:
print ("\tAddress: " + reply['fields']['address'])
if "sex" in reply['fields']:
print ("\tGender: " + reply['fields']['sex'])
if "birth" in reply['fields']:
print ("\tDate of birth: " + reply['fields']['birth'])
@symisc
Copy link
Author

symisc commented Mar 11, 2020

Scan an ID card using the PixLab /docscan API endpoint.

Given a government issued ID card from India, Malaysia, Singapore, etc., extract the user face and parse all fields.

PixLab recommend that you connect your AWS S3 bucket via your dashboard at https://pixlab.io/dashboard
so that any cropped face or MRZ crop is stored automatically on your S3 bucket rather than the PixLab one.
This feature should give you full control over your analyzed media files.

https://pixlab.io/cmd?id=docscan for additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment