Skip to main content
The official travel or identity documents of many countries contain a machine-readable zone (MRZ) that ensures more accurate processing of the document data. The MRZ includes 2 or 3 lines with the OCR-B font text written in accordance with ICAO Document 9303 (see the specifications on the ICAO website). This scenario is used for extracting data from a machine-readable zone on ID documents during customer onboarding or verification processes. The system recognizes MRZ on the document image and extracts the data from it. The extracted data contains several fields with the personal information about the document and its holder (document’s type and expiry date, the first and the last names of the document holder, etc.). You may search through the fields, verify the data and save it to an external file for further processing. To extract the data from MRZ, image files obtained by scanning or saved in the electronic format typically go through several processing stages, each of which has its own peculiarities:
  1. Preprocessing of scanned images or photos You either scan or take a photo of an ID document’s identity page with MRZ. Photos made with digital cameras of mobile devices may have low resolution and quality. Also, images may require some preprocessing prior to recognition.
  2. Extracting data from MRZ No more than one MRZ may be captured from each image. The text of each of the 2 or 3 lines will be recognized and parsed to extract the data fields. Some of the fields and the MRZ as a whole have checksums, which will help you to verify the data.
  3. Export to an external file You may also save the extracted data in an external format: XML and JSON are supported.
The procedure described below is implemented in the MRZExtraction code sample for Linux and Windows.

Scenario implementation

The code samples provided in this topic are Windows -specific.
Below is the detailed description of the recommended method of using ABBYY FineReader Engine 12 in this scenario. The proposed method uses processing settings that are most suitable for this scenario.
To start your work with ABBYY FineReader Engine, you need to create the Engine object. The Engine object is the top object in the hierarchy of the ABBYY FineReader Engine objects and provides various global settings, some processing methods, and methods for creating the other objects.To create the Engine object, you can use the InitializeEngine function. See also other ways to load Engine object (Win).

C#

You can load the processing settings suitable for this scenario using the LoadPredefinedProfile method of the Engine object. This method uses the name of a settings profile as an input parameter. Please see Working with Profiles for more information.The settings for this scenario are available in the MachineReadableZone predefined profile:
  • Enables detection and extraction of all text on an image (pictures, vector graphics and tables are not detected).
  • Resolution and geometry correction are performed automatically.

C#

If you wish to change processing settings, use appropriate parameter objects. Please see Additional optimization for specific tasks below for further information.MRZ capture is only possible if your ABBYY FineReader Engine license supports the MRZCapture module.
To load images to FineReader Engine, you can use the methods of these objects:
Linux and Windows users can learn about the advantages and disadvantages of each approach in Parallel Processing with ABBYY FineReader Engine. The current topic focuses on FRDocument.
To load images to the FRDocument object, do one of the following:All these methods take as an input parameter a PrepareImageMode object which allows you to specify different parameters of image preprocessing. Create this object by calling the IEngine::CreatePrepareImageMode method, then change its properties as necessary and pass it to the image opening method.

C#

To extract data from MRZ:
  1. [optional] Create the MrzProcessingParams object with the help of the CreateMrzProcessingParams method of the Engine object. Set up its properties to the values you need.
  2. Call the ExtractMrz method of the FRPage object, passing the MrzProcessingParams object you configured in the previous step as the input parameter; for default MRZ capture settings, simply pass NULL. You will receive an MrzData object containing the parsed information from the captured MRZ.

C#

The MrzData object contains all the data extracted from the MRZ. You may access the lines of machine-readable text using the GetLine method and iterate through fields using the GetField and GetFieldByType methods. The fields of the following types are extracted:
  • Document type
  • Document subtype
  • Issuing country
  • Last name
  • Given name
  • Document number
  • Nationality
  • Birth date
  • Sex
  • Expiry date
  • Personal number
  • Optional data line 1
  • Optional data line 2
The MrzField object provides the complete information about the extracted field. Use its Text property to get the field value and the Region property to get the field location on the image. To verify the data, use the checksums available through the Checksum, HasChecksum and IsChecksumVerified properties of the MrzData and MrzField objects. Not all the field types support checksums; the HasChecksum property is provided so that you can check its value before trying to retrieve the checksum.You may edit the recognized text of the fields manually using the Insert and Remove methods of the MrzField object.

C#

The extracted data may be saved to an XML or JSON file. To export the data with the default parameters, call the ExportToFile method of the MrzData object and pass the path to the file as an input parameter. To export the data with the user-defined parameters, call the ExportToFileEx method of the MrzData object and pass the pointer to the MrzJsonExportParams object or the MrzXmlExportParams object as an input parameter.C#
After finishing your work with ABBYY FineReader Engine, you need to unload the Engine object. To do this, use the DeinitializeEngine exported function.

C#

Required resources

You can use the FREngineDistribution.csv file to automatically create a list of files required for your application to function. For processing with this scenario, select in the column 5 (RequiredByModule) the following values: Core Core.Resources Opening Opening, Processing Processing Processing.OCR Processing.OCR, Processing.ICR Processing.OCR.NaturalLanguages Processing.OCR.NaturalLanguages, Processing.ICR.NaturalLanguages Export Export, Processing If you modify the standard scenario, change the required modules accordingly. You also need to specify the interface languages, recognition languages and any additional features which your application uses (such as, e.g., Opening.PDF if you need to open PDF files). See Working with the FREngineDistribution.csv File for further details.

Additional optimization

These are the sections of the Help file where you can find additional information about setting up the parameters for the various processing stages:

See also

Basic Usage Scenarios Implementation