Table of contents

Configure MRZ Scanner

When developing with MRZScannerActivity, you can add configurations via the MRZScannerConfig class. This page will guide you on how to configure the settings.

Scan Document Type

Set the document type via APIs

Specifies the type of document to scan, such as ID cards or passports. It also improves the processing speed and the accuracy.

  • Java
  • Kotlin
  1. MRZScannerConfig config = new MRZScannerConfig();
    config.setDocumentType(EnumDocumentType.DT_PASSPORT);
    
  2. val config = MRZScannerConfig().apply {
       documentType = EnumDocumentType.DT_PASSPORT
    }
    

Setup a customized template file

A template file is a JSON file that includes a series of algorithm parameter settings. It is always used to customize the performance for different usage scenarios. Contact us to get a customized template for your scanner.

  1. Add a Templates folder to the assets folder of your project at src\main\assets\Templates. Put your JSON file in the Templates folder.

  2. Specify the template file via setTemplateFile

  • Java
  • Kotlin
  1. MRZScannerConfig config = new MRZScannerConfig();
    config.setTemplateFile("CustomizedTemplate.json");
    
  2. val config = MRZScannerConfig().apply {
       templateFile = "CustomizedTemplate.json"
    }
    

You can also use a JSON string as the template file.

Related APIs

Configure the UI Elements

mrz-scanner

MRZ Scanner UI Component

  • Close button: Stop MRZ scanning and go back to the previous activity.
  • Torch button: A clickable button that can turn on/off the torch.
  • Java
  • Kotlin
  1. MRZScannerConfig config = new MRZScannerConfig();
    config.setTorchButtonVisible(false);
    config.setGuideFrameVisible(false);
    config.setCloseButtonVisible(false);
    
  2. val config = MRZScannerConfig().apply {
       torchButtonVisible = false
       guideFrameVisible = false
       closeButtonVisible = false
    }
    

Related APIs

Beep

Let the app to trigger a beep sound when MRZ is scanned successfully.

  • Java
  • Kotlin
  1. MRZScannerConfig config = new MRZScannerConfig();
    config.setBeepEnabled(true);
    
  2. val config = MRZScannerConfig().apply {
       isBeepEnabled = true
    }
    

Related API

Further Customization

If you have other customization requirements on the MRZScanner component, you can modify it with the open source code on GitHub.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: