MRZ Scanner Guide
for
Android

SDK v.1.10.5

Installation guide


Please follow these simple steps to integrate our SDK into your Android project:


android:id="@+id/scannerFragment"

android:name="com.scansolutions.mrzscannerlib.MRZScanner"

android:layout_width="match_parent"

android:layout_height="match_parent" />



MRZScanner mrzScanner = (MRZScanner) getSupportFragmentManager().findFragmentById(R.id.scannerFragment);

mrzScanner.setScannerType(ScannerType.SCANNER_TYPE_MRZ); // Options: [SCANNER_TYPE_MRZ, SCANNER_TYPE_DOC_IMAGE_ID, SCANNER_TYPE_DOC_IMAGE_PASSPORT, TYPE_DRIVING_LICENCE]

MRZScanner.setIDActive(true);          // Enable/disable the ID document type

MRZScanner.setPassportActive(true);    // Enable/disable the Passport document type

MRZScanner.setVisaActive(true);        // Enable/disable the Visa document type

MRZScanner.setMaxThreads(2);           // Set the max CPU threads that the scanner can use

MRZScanner.registerWithLicenseKey(this, "licence_key", new MRZLicenceResultListener() {

   @Override

   public void onRegisterWithLicenceResult(int result, @Nullable String errorMessage) {

       if (errorMessage != null) {

           Log.i(TAG, "Result code: " + result + ". " + errorMessage);

       } else {

           Log.i(TAG, "Result code: " + result + ". Registration successful.");

       }

   }

});



String sdkVersion = MRZScanner.sdkVersion(); // Get the current SDK version of MRZScanner



public class MainActivity extends AppCompatActivity implements MRZScannerListener { ...


class MainActivity : AppCompatActivity(), MRZScannerListener { ...


API description



/**

* Set the scanning rectangle to limit the scanning area. The parameters' values are representing percentages of the scanning preview.

*

* @param x      the top left point of the scanning rectangle. [0,...,100] Default value: 5.

* @param y      the top left point of the scanning rectangle. [0,...,100] Default value: 20.

* @param width  width the width of the scanning rectangle. [0,...,100] Default value: 90.

* @param height height the height of the scanning rectangle. [0,...,100] Default value: 60.

*/

public void setScanningRectangle(int x, int y, int width, int height)



/**

* Specify whether the scanner should detect and return result for IDs.

*

* @param isIDActive [true, false]. The default value is true.

*/

public static void setIDActive(boolean isIDActive)



/**

* Specify whether the scanner should detect and return result for passports.

*

* @param isPassportActive [true, false]. The default value is true.

*/

public static void setPassportActive(boolean isPassportActive)



/**

* Specify whether the scanner should detect and return result for visas.

*

* @param isVisaActive [true, false]. Default value is true.

*/

public static void setVisaActive(boolean isVisaActive)



/**

* Specify the maximum number of CPU threads that the scanner can use during the scanning process.

*

* @param maxThreads number of CPU threads. Default value is 2.

*/

public static void setMaxThreads(int maxThreads) 



/**

* Specify which scanner type you want to use. There are two options: "MRZ Scanner" and "Document Image scanner".

* The "MRZ Scanner" option is used to scan for MRZ.

* The "Document image scanner" is used for capturing front and back image of the ID documents.

*

* @param scannerType [SCANNER_TYPE_MRZ, SCANNER_TYPE_DOC_IMAGE_ID, SCANNER_TYPE_DOC_IMAGE_PASSPORT]. Default value is SCANNER_TYPE_MRZ

*/

public void setScannerType(ScannerType scannerType)



/**

* Resume scanning after the scanner has been paused/stopped. Usually after a successful scan.

*/

public static void resumeScanning() 



/**

* Register with the licence key provided to remove the asterisks (*) from the result.

*

* @param context                   the activity's context.

* @param key                       the provided licence key.

* @param mrzLicenceResultListener  register result callback where int @result is 0 when registration is successful <0 when registration failed.

*                                  @errorMessage is null when registration is successful, otherwise @errorMessage is an error description String.

*/

public static void registerWithLicenseKey(final Context context, final String key, @Nullable final MRZLicenceResultListener mrzLicenceResultListener)



/**

* Register with the licence key provided to remove the asterisks (*) from the result.

*

* @param context the activity's context.

* @param key     the provided licence key.

* @return 0 for success, <0 if registration failed.

*

* @deprecated use {@link MRZScanner#registerWithLicenseKey(Context, String, MRZLicenceResultListener)} instead.

*/

@Deprecated

public static int registerWithLicenseKey(final Context context, final String key) 



/**

* Scan for a single bitmap.

*

* @param bitmap   the image to be scanned.

* @param activity the initialisation activity context.

*/

public static void scanBitmap(final Bitmap bitmap, final Activity activity, final MRZScannerListener listener)



/**

* Trigger an image picker.

*

* @param activity the initialisation activity context.

*/

public static void scanFromGallery(final Activity activity, final MRZScannerListener listener)



/**

* Show a warning alert dialog if the camera's resolution is lower than 5 MP and if the camera lacks the AutoFocus feature.

*

* @param shouldWarn [true, false]. Default value is true.

*/

public static void warnIncompatibleCamera(boolean shouldWarn)



/**

* Set valid issuing country codes. Successful scans with country codes not included in the array will be ignored.

*

* @param validIssuingCountries array with active country codes. Example value: new String[]{"foo", "bar"}.

*/

public static void setValidIssuingCountries(String[] validIssuingCountries) 



/**

* Set custom overlay image for the scanner.

*

* @param customImage bitmap representation of the overlay image

*/

public void setCustomImageOverlay(Bitmap customImage)

/**

* Set custom overlay image for the scanner.

*

* @param customImageResId resource id of the overlay image

*/

public void setCustomImageOverlay(int customImageResId) 


/**

* Enable scan from gallery. If enabled, a "scan from gallery" button will appear in the scanner preview.

*

* @param enabled indicates whether the "scan from gallery"  is enabled. Default value: false.

*/

public void enableScanFromGallery(boolean enabled) 


/**

* Enable upside-down scanning. If enabled, the scanner will also try the upside-down format of the preview.

*

* @param enabled indicates whether the "upside-down" feature  is enabled. Default value: false.

*/

public static void setEnableUpsideDownScanning(boolean enabled)


/**

* Set valid nationality and issuing country codes. Successful scans with country codes not included in the array will be ignored.

*

* @param validCountryCodes array with active country codes. Example value: new String[]{"GBR", "USA"}. Default: {} (ALL).

*/

public static void setValidCountryCodes(String[] validCountryCodes)


/**

* Specify whether validation of country codes is enabled.

*

* @param enabled indicates whether validation is enabled. Default: true.

*/

public static void setValidateCountryCodesEnabled(Boolean enabled)


/**

* Turn flash on or off.

*

* @param on true = on, false = off. Default value: false.

*/

public void toggleFlash(Boolean on)


/**

* Enable vibration on successful scan.

*

* @param enabled indicates whether the vibration feature  is enabled. Default value: true.

*/

public static void setEnableVibrationOnSuccess(boolean enabled)



/**

* Continuous scanning. If enabled, after successful scan, the scanner view will not be paused.

*

* @param enabled indicates whether the scanner should stay active after a successful scan. Default value: false.

*/


public void setContinuousScanningEnabled(boolean enabled) 

/**

* Ignore duplicates when scanning continuously.

*

* @param ignore indicates whether the scanner should repeat the last successful scan. Default value: true.

*/

public void setIgnoreDuplicates(boolean ignore) 


/**

* Choose the effort level that the scanner should apply for detecting a MRZ.

*

* @param effortLevel available options [EFFORT_LEVEL_CASUAL, EFFORT_LEVEL_TRY_HARDER, EFFORT_LEVEL_SWEATY]. Default value: EFFORT_LEVEL_TRY_HARDER.

*/

public void setEffortLevel(MRZEffortLevel effortLevel)


/**

* Perform face detection when scanning a passport to locate the portrait image and return it as part of MRZResultModel if detected.

* This feature is only available for Passport document types.

*

* @param enabled indicates whether or not to perform this action. Default value: true.

*/

public static void setExtractPortraitEnabled(boolean enabled)


/**

* Find and return an image of the signature as part of MRZResultModel.

* This feature is only available for Passport document types.

*

* @param enabled indicates whether or not to perform this action. Default value: true.

*/

public static void setExtractSignatureEnabled(boolean enabled)


/**

* Find and return a full image of the document as part of MRZResultModel.

* This feature is only available for Passport document types.

*

* @param enabled indicates whether or not to perform this action. Default value: true.

*/

public static void setExtractFullPassportImageEnabled(boolean enabled) 


/**

* Capture an image of the back of the ID document as part of MRZResultModel when a successful scan has been made.

*

* @param enabled indicates whether or not to perform this action. Default value: true.

*/

public static void setExtractIdBackImageEnabled(boolean enabled) 


/**

* If enabled, the scanner will ignore results if check digits are not valid.

* Disabling it increases the chances of misread.

*

* @param enabled default value: true.

*/

public static void setIgnoreInvalidCheckDigitsEnabled(boolean enabled) 


/**

* Show flash button.

*

* @param enabled indicates whether or not to show flash button. Default value: true.

*/

public void setShowFlashButton(boolean enabled)


CHANGELOG


- v1.10.6

- v1.10.5

- v1.10.4

- v1.10.3

- v1.10.0


- v1.9.1


- v1.9.0


- v1.8.2


- v1.8

-v1.7.1


-v1.7

 


- v1.6


- v1.5:



If you have any questions or concerns please visit our site at www.mrzscanner.com where you can register and send us a support request ticket at our Developer Portal, or feel free to contact us at contact@mrzscanner.com.