Modern Passport Structure & Bulk Scan APIs

A Passport is a document that almost everyone has at some point in their lives. It is issued by the country’s government to its citizens and mainly being used for traveling purposes. It also serves as proof of nationality, name, and more importantly an Universally Unique ID for its owner.

Modern Passport Structure

Passport Specimen

Many services have been long-time accepting passports as identification documents from their customers to complete their KYC (Know Your Customer) form as required by the legislation in force. This is especially true and enforced for the Finance, HR or Travel sectors. In most cases, a human operator will verify the authenticity of the submitted document and grant validation or reject it.

Things can get really complicated if you have hundreds of KYC forms to checks, but also if your clients differ in nationality. Quickly, you will find yourself drowning in physical copies of passports in different languages that you can not even understand. Let alone the potential legal problems you can face with passport copies laying around the office. This is why, an automated & safe solution for Passports processing is required!

Modern Passport Structure

From the 1980s on wards, most countries started issuing passports containing an MRZ. MRZ stands for the Machine Readable Zone and is usually located at the bottom of the Passport as shown below:

Modern Passport Specimen

Passports MRZ Sample

Passports that contain an MRZ are referred to as MRPs, machine-readable passports (Almost all modern issued Passports have one). The structure of the MRZ is standardized by the ICAO Document 9303 and the International Electro-technical Commission as ISO/IEC 7501-1.

The MRZ is an area on the document that can easily be read by a machine using an OCR Reader Application or API. It’s not important for you to understand how it works, but if you look at it carefully, you will see that it contains most of the relevant information on the document, combined with additional characters and a checksum that can be extracted programmatically and automatically via API as we will see in the next section.

Once parsed, the following information are automatically extracted from the target MRZ and made immediately available to your app, thanks to the /docscan API endpoint:

  • issuingCountry: The issuing country or organization, encoded in three characters.
  • fullName: Passport holder full name. The name is entirely upper case.
  • documentNumber: This is the passport number, as assigned by the issuing country. Each country is free to assign numbers using any system it likes.
  • checkDigit: Check digits are calculated based on the previous field. Thus, the first check digit is based on the passport number, the next is based on the date of birth, the next on the expiration date, and the next on the personal number. The check digit is calculated using this algorithm.
  • nationality: The issuing country or organization, encoded in three characters.
  • dateOfBirth: The date of the passport holder's birth in YYMMDD form. Year is truncated to the least significant two digits. Single digit months or days are perpended with 0.
  • sex: Sex of the passport holder, M for males, F for females, and < for non-specified.
  • dateOfExpiry: The date the passport expires in YYMMDD form. Year is truncated to the least significant two digits. Single digit months or days are perpended with 0.
  • personalNumber: This field is optional and can be used for any purpose that the issuing country desires.
  • finalcheckDigit: This is a check digit for positions 1 to 10, 14 to 20, and 22 to 43 on the second line of the MRZ. Thus, the nationality and sex are not included in the check. The check digit is calculated using this algorithm.

Automatic Passport Processing

PixLab Logo

Fortunately for the developer wishing to automate Passports scanning, PixLab can automatically scan & extract passport MRZ but also help to detect possible fraudulent documents. This is made possible thanks to the /docscan API endpoint which let you in a single call scan government issued documents such as Passports, Visas or ID Cards from various countries.

Besides extracting MRZ, the /docscan API endpoint shall automatically crop any detected face and transform binary Machine Readable Zone into stream of text content (i.e. full name, issuing country, document number, date of expiry, etc.) ready to be consumed by your app in the JSON format.

Below, a typical output result of the /docscan endpoint for a passport input image:

Input Passport Specimen (JPEG/PNG/BMP Image)

Input Image URL

Extracted MRZ Fields

MRZ Fields

What follow is the gist used to achieve such result:

Other document scanning code samples are available to consult via the following Github links:

Face extraction is automatically performed using the /facedetect API endpoint. For a general purpose Optical Character Recognition engine, you should rely on the /OCR API endpoint instead. If you are dealing with PDF documents, you can convert them at first to raw images via the /pdftoimg endpoint.

Conclusion

The era we are in is more digitized than ever. Tasks that are repetitive are slowly being replaced by computers and robots. In many cases, they can perform these tasks faster, with a smaller amount of mistakes and in a more cost-effective manner. At PixLab we focus on building software to replace manual repetitive labor in administrative business processes. The processing and checking of passports can be very time-consuming. Using /docscan to automate your passport processing will enable you to save cost, on-board customers faster and reduce errors in administrative processes.

Detect & Blur Faces Programmatically using PixLab

Our colleague Vincent just published an interesting blog post on how to automatically detect and blur faces at real-time using the PixLab API with a nice introduction on how modern face detection algorithms works under the hood and the privacy concerns related to such use of technology!

Blurred Faces

Talkie OCR - Image to Speech Now on the App Store

Developed by our colleague Mrad Chams from Symisc Systems and entirely powered by the PixLab OCR API endpoint.

Talkie OCR - Image to Speech

Talkie OCR - A state-of-the-art OCR scanner that practically turn almost any images with human readable characters into text content which is in turn transformed into human voice in your native language & accent. Built in features includes:

  • Automatically Recognize the Input Language & Speaks your Accent: Once the scanned image (Book page, magazine, journal, scientific paper, etc.) recognized & transformed into text content, you'll be able to playback that text in your local accent & over 45 languages of your choice!
  • State of the art OCR processing algorithm powered by PixLab.
  • Speaks over 45 languages with their accents.
  • Built-in translation service to over 30 foreign languages of your choice.
  • Built-in Vision Impaired Mode with the ability to recognize the input language automatically.
  • Playback Pause & Resume at Request.
  • Offline Save for Later Read & Playback.

Download on the App Store Get it on Google Play

PixLab API 1.9.72 Released!

The PixLab development team is pleased to announce the immediate availability of the PixLab API 1.9.72.

PixLab Logo

Since its launch on 2017, PixLab have already processed over 450 Millions of users contents whether static images, GIF or Videos Frames. This milestone release introduces new API endpoints, various minor bug fixes, processing speed improvements by up to 5% and many innovative features. Let's start with the one we are existed about in no particular order:

  • Passports & ID Cards Scan: While documents scanning were introduced in earlier version of the PixLab API via the /docscan endpoint. This release pushes further the accuracy of the OCR engine. A 5MB raw Passport sample now takes less than 3 seconds to execute including face detection & extraction, MRZ (Machine Readable Zone) extraction and finally transformation of the Raw MRZ data into textual content. You can try out the accuracy of the Passport scanning engine using these Python and PHP scripts to see it in action.
  • DNS infrastructure moved to Cloudflare for faster than ever response times.
  • Full support for HTTP/2 and HTTP/3 (QUIC).
  • Up to three layers of redundancy for the standard PixLab OCR engine for faster, accurate & guaranteed scan results.
  • A fresh update of the adult & gore content detection ML model which is used to power the famous PixLab /NSFW API endpoint that have already analyzed over 100 millions of user contents with high accuracy.
  • Face Detection (including facial landmarks extraction) & Emotion Pattern (including gender & age) extraction are now using the RetinaFace Model which scores the highest on the LFW dataset.
  • The /docscan API endpoint now fully support scanning ID cards from Malaysia & Singapore and many other countries (at users request) as well the brand new India Aadhar ID card. Find out more information about Aadhard fully support via our blog announcement here.
  • Finally, a brand new, high performance custom image processing layer written in C/C++ and powered by ImageMagick and our Embedded computer Vision Library SOD is integrated directly into our cloud API.

Pixlab customers are more than advised to take a look at The official API endpoints documentation, The Samples Page, The Github repository for additional information.

Finally, for potentially interested users, you are more than welcome to start a 7 days free trial to see the API in action. Simply head to the PixLab Dashboard and activate your free trial from there.

PixLab Logo

Passports, Travel Documents & ID Cards Scan API Endpoint Available

The PixLab OCR team is pleased to introduce the /docscan API endpoint which let you in a single call scan government issued documents such as Passports, Visas or ID Cards from various countries.

Besides its accurate text scanning capabilities, the /docscan API endpoint shall automatically extract any detected face and transform binary data such as Passport Machine Readable Zone (MRZ) into stream of text payload (i.e. full name, issuing country, document number, date of expiry, etc.) ready to be consumed by your app in the JSON format.

Below, a typical output result of the /docscan endpoint for a passport input image:

Input Passport Specimen (JPEG/PNG/BMP Image)

Input Image URL

Extracted MRZ Fields

MRZ Fields

The code samples used to achieve such result are available to consult via the following Github links:

Face extraction is automatically performed using the /facedetect API endpoint. For a general purpose Optical Character Recognition engine, you should rely on the /OCR endpoint instead. If you are dealing with PDF documents, you can convert them at first to raw images via the /pdftoimg endpoint.

Below, a typical Python code snippet for scanning passports:

import requests
import json

# Given a government issued passport document, extract the user face and parse all MRZ 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://i.stack.imgur.com/oJY2K.png', # Passport sample
    'type':'passport', # Type of document we are a going to scan
    'key':'Pixlab_key'
})
reply = req.json()
if reply['status'] != 200:
    print (reply['error'])
else:
    print ("User Cropped Face: " + reply['face_url'])
    print ("MRZ Cropped Image: " + reply['mrz_img_url'])
    print ("Raw MRZ Text: " + reply['mrz_raw_text'])
    print ("MRZ Fields: ")
    # Display all parsed MRZ fields
    print ("\tIssuing Country: " + reply['fields']['issuingCountry'])
    print ("\tFull Name: "       + reply['fields']['fullName'])
    print ("\tDocument Number: " + reply['fields']['documentNumber'])
    print ("\tCheck Digit: "   + reply['fields']['checkDigit'])
    print ("\tNationality: "   + reply['fields']['nationality'])
    print ("\tDate Of Birth: " + reply['fields']['dateOfBirth'])
    print ("\tSex: "           + reply['fields']['sex'])
    print ("\tDate Of Expiry: "    + reply['fields']['dateOfExpiry'])
    print ("\tPersonal Number: "   + reply['fields']['personalNumber'])
    print ("\tFinal Check Digit: " + reply['fields']['finalcheckDigit'])

Finally, the official endpoint documentation is available to consult at pixlab.io/cmd?id=docscan and a set of working samples in various programming language are available at the PixLab samples pages.

Automatically Filter Image Uploads According to their NSFW Score

Our colleague Vincent just published an interesting blog post on dev.to on how to automatically filter images uploads (GIF included) according to their NSFW score via the PixLab NSFW API endpoint and apply a blur filter if adult, nudity or gory details is detected. Find out more information via the following links:

ASCII ART Camera Effect Model Now Available on the Unity Asset Store

The PixLab development team is thrilled to announce the immediate availability of the ASCII ART Camera Model in the Unity Asset Store!

ASCII Camera let you transform your input camera stream, video frames or static images/textures into ASCII glyphs & printable characters at real-time.

ASCII Camera Effect

Real-Time performance (even on low end Android devices) of the ASCII Camera asset is achieved via pixel intensity comparison inside internal nodes of a single decision tree. The Unity implementation is based on this paper.

ASCII Camera in the Asset Store

Finally, the ASCII Camera documentation, demo & source code are available via the following links:

PixLab on Social Media Platforms

Follow PixLab on social media to keep up-to-date with the latest company news, research highlights and benefit from a range of useful resources including (but not limited to) our brand new API services such the state-of-the-art Passports & ID Cards scanning API, the new facial recognition engine which achieve 99.8% success ratio and many more API endpoints for building intelligent applications.

PixLab Logo

Don't forget! You can instantly reach our support team via the PixLab dashboard and we always guaranty a response in 48 business hours timeframe for your integration and support assistance!

Full Scan Support for India Aadhar ID Card

The PixLab OCR team is pleased to announce that is now fully support scanning India Aadhar ID Cards besides Malaysia (MyKad) and Singapore identity cards as well governments issued Passports from all over the world via the /docscan API endpoint.

When invoked, the /docscan API endpoint shall Extract (crop) any detected face and transform the raw Aadhar ID card content such as holder name, gender, date of birth, ID number, etc. into a JSON object ready to be consumed by your app.

Below, a typical output result of the /docscan API endpoint for a Aadhar ID card input sample:

Input Aadhar ID Card

ID card specimen

Extracted Aadhar Card Fields

extracted fields

The same API call applies for Passports as well different ID cards from supported countries (you just specify the country name or ISO code):

Input Passport Specimen

Passport Specimen

Extracted MRZ Fields

MRZ Fields

The code samples used to achieve such result are available to consult via the following Github links:

Face extraction is automatically performed using the /facedetect API endpoint. If you are dealing with PDF documents, you can convert them at first to raw images via the /pdftoimg endpoint.

Finally, the official endpoint documentation is available to consult at pixlab.io/cmd?id=docscan and a set of working samples in various programming language are available at the PixLab samples pages.

SOD CV/ML Library 1.1.8 Released

The PixLab development team is pleased to announce the immediate availability of the 1.1.8 release of our Embedded Computer Vision & Machine Learning library SOD.

SOD Face detection

SOD is an embedded, modern, cross-platform, computer vision and machine learning C/C++ library that expose a set of APIs for deep-learning, advanced media analysis & processing including real-time, multi-class object detection and model training on embedded systems with limited computational resource and IoT devices. At PixLab, we believe SOD is:

  • Suitable for deep learning on limited computational resource, embedded systems and IoT devices.
  • Easy to integrate with existing code bases. Interpolatable with OpenCV and/or any other proprietary API.

SOD is shipped with a real-time face detection & tracking model (download link) that has been ported to Unity, Unreal Engine and WebAssembly.

Finally, you can find out more information about the SOD project via the following links: