‚Äč

Cloud OCR SDK Documentation

processMRZ Method

This method finds a machine-readable zone on the image and extracts data from it.
Machine-readable zone (MRZ) is typically found on official travel or identity documents of many countries. It can have 2 lines or 3 lines of machine-readable data. This method allows to process MRZ written in accordance with ICAO Document 9303 (endorsed by the International Organization for Standardization and the International Electrotechnical Commission as ISO/IEC 7501-1)).

[POST] http(s)://cloud.ocrsdk.com/processMRZ

The image file is transmitted in the request body. See the list of supported input formats.

The result of recognition is returned in XML format.

For details on task cost please see billing terms.

Examples of documents with MRZ

The 2-line MRZ can be found, for example, in Russian international passport:

Russian Federation foreign passport

The 3-line MRZ see on this example of Kazakhstan identity card:

Kazakhstan identity card

Parameters

This method has no parameters.

Status codes and response format

General status codes and response format of the method are described in HTTP Status Codes and Response Formats.

The following status codes can be returned when this method is called:

CodeDescription
200 Successful method call.
450

Exceeded quota to add images. This error is returned if the number of images you have uploaded exceeds the number of images you can process with the credits available on your account plus some threshold. You can resolve this issue by topping up your account or by removing the tasks which have been submitted but have not been processed.

551

The format of the image file passed for processing is not supported.

Output file format

The output XML file has the following format:

<?xml version="1.0" encoding="utf-8"?>
<document type="mrz" xmlns="http://ocrsdk.com/schema/captureData-1.0.xsd">
  <field type="LastName">
    <value>MALBORSKYI</value>
  </field>
  <field type="DocumentNumber">
    <value>755327941</value>
  </field>   
   ...

</document>

If the output file contains empty <document/> tag no MRZ was found on the recognized image.

See the XSD scheme of an output file.

Possible field types of the machine-readable zone

Field typeDescription
MrzType

The number of lines in MRZ. It can have one of the following values:

  • 2line
  • 3line

The example of a 2-line MRZ:
P<RUSMALBORSKYI<<KOVBOJ<<<<<<<<<<<<<<<<<<<<<
7553279419RUS8712242M2104131<<<<<<<<<<<<<<02

Line1

All characters of the first line of machine readable zone.

Example: P<RUSMALBORSKYI<<KOVBOJ<<<<<<<<<<<<<<<<<<<<<

Line2

All characters of the second line of machine readable zone.

Example: 7553279419RUS8712242M2104131<<<<<<<<<<<<<<02

Line3 All characters of the third line of machine readable zone (if exists).
DocumentType

The type of a document. It is the first character of the first line.

Example: P, which indicates a passport.

DocumentSubtype The subtype of a document (if exists). It is the second character of the first line.
IssuingCountry

Code of issuing state (ISO 3166-1 alpha-3 code).

Example: RUS

LastName

Surname.

Example: MALBORSKYI

GivenName

One or several given names separated with the space character.

Example: KOVBOJ

DocumentNumber

The number of a document.

Example: 755327941

DocumentNumberVerified

The Boolean value that specifies whether the checksum over the document number matches the check digit. It can have one of the following values:

  • true
  • false
DocumentNumberCheck

The check digit over the document number.

Example: 9

Nationality Nationality (ISO 3166-1 alpha-3 code).

Example: RUS

BirthDate

Date of birth in the format: YYMMDD.

Example: 871224

BirthDateVerified

The Boolean value that specifies whether the checksum over the birth date matches the check digit. It can have one of the following values:

  • true
  • false
BirthDateCheck

The check digit over the birth date.

Example: 2

Sex

Sex. It can have one of the following values:

  • M
  • F
  • <
ExpiryDate

Date of expiry in the format: YYMMDD.

Example: 210413

ExpiryDateVerified

The Boolean value that specifies whether the checksum over the expiry date matches the check digit. It can have one of the following values:

  • true
  • false
ExpiryDateCheck

The check digit over the expiry date.

Example: 1

PersonalNumber Personal number. Personal number and its check digit are optional in MRZ.
PersonalNumberVerified

The Boolean value that specifies whether the checksum over the personal number matches the check digit. It can have one of the following values:

  • true
  • false
PersonalNumberCheck

The check digit over the personal number. Personal number and its check digit are optional in MRZ.

OptionalDataLine1 Optional data from the first line of the 3-line MRZ.
OptionalDataLine2 Optional data from the second line of the 3-line MRZ.
Checksum

The check digit over the document number, birth date, expiry date, personal number, optional data, and their check digits.

Example: 2

ChecksumVerified

The Boolean value that specifies whether the checksum over the document number, birth date, expiry date, personal number, optional data, and their check digits matches the check digit. It can have one of the following values:

  • true
  • false

You can check the quality of data extraction by the value of this field. However note that there is no check digit over the surname and given names. Therefore these fields may contain recognition errors even if the checksum over all other fields matches the check digit. 

For more information on MRZ standard see Wikipedia.