Documentation / MRZ Scanner 1.x (archive) / Android
On this page
- setScanningRectangle
- setIDActive
- closeScanner
- setPassportActive
- setVisaActive
- setMaxThreads
- setZoomFactor
- setScannerType
- resumeScanning
- registerWithLicenseKey
- sdkVersion
- @return the current SDK Version.
- setDateFormat
- scanBitmap
- scanFromGallery
- warnIncompatibleCamera
- setValidCountryCode
- setCustomImageOverlay
- setCustomImageOverlay
- enableScanFromGallery
- setEnableUpsideDownScanning
- setValidateCountryCodesEnabled
- public void toggleFlash
- setEnableVibrationOnSuccess
- setContinuousScanningEnabled
- setIgnoreDuplicates
setScanningRectangle
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 the width of the scanning rectangle. [0,...,100]Default value: 90.
@param height the height of the scanning rectangle. [0,...,100]Default value: 60.
public void setScanningRectangle(int x, int y, int width, int height)
setIDActive
Specify whether the scanner should detect and return result for IDs.
@param isIDActive [true, false]. The default value is true.
public void setIDActive(boolean isIDActive)
closeScanner
Stop and close the MRZ Scanner
public void closeScanner()
setPassportActive
Specify whether the scanner should detect and return result for passports.
@param isPassportActive [true, false]. The default value is true.
public void setPassportActive(boolean isPassportActive)
setVisaActive
Specify whether the scanner should detect and return result for visas.
@param isVisaActive [true, false]. Default value is true.
public void setVisaActive(boolean isVisaActive)
setMaxThreads
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 void setMaxThreads(int maxThreads)
setZoomFactor
Set the zoom factor for the camera preview.
@param float. Default value is 1.0
public static void setZoomFactor(float zoomFactor)
setScannerType
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)
resumeScanning
Resume scanning after the scanner has been paused/stopped. Usually after a successful scan.
public void resumeScanning()
registerWithLicenseKey
Register with the licence key provided to remove the asterisks (*) from the result.
@param key the provided licence key.
@return 0 for success, -1 if registration failed.
public int registerWithLicenseKey(String key)
To get your evaluation key today, register an account on https://mrzscanner.com/register
sdkVersion
@return the current SDK Version.
public static String sdkVersion()
setDateFormat
Set the date format in which the parsed dates are formatted.
@param dateFormat the pattern describing the date format. Example: "dd.MM.YYYY"
@return the currently set date format in which the parsed dates are formatted.
public static void setDateFormat(String dateFormat)
scanBitmap
Scan for a single bitmap.
@param bitmap the image to the scanned.
@param activity the initialization activity context.
public static void scanBitmap(final Bitmap bitmap, final Activity activity, final MRZScannerListener listener)
scanFromGallery
Trigger image picker.
@param activity the initialization activity context.
public static void scanFromGallery(final Activity activity, final MRZScannerListener listener)
warnIncompatibleCamera
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)
setValidCountryCode
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 setValidCountryCode(String[] validIssuingCountries)
setCustomImageOverlay
Set custom overlay image for the scanner.
@param customImage bitmap representation of the overlay image
public void setCustomImageOverlay(Bitmap customImage)
setCustomImageOverlay
Set custom overlay image for the scanner.
@param customImageResId resource id of the overlay image
public void setCustomImageOverlay(int customImageResId)
enableScanFromGallery
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)
setEnableUpsideDownScanning
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)
setValidateCountryCodesEnabled
Specify whether validation of country codes is enabled.
@param enabled indicates whether validation is enabled. Default: true.
public static void setValidateCountryCodesEnabled(Boolean enabled)
public void toggleFlash
Turn flash on or off.
@param on true = on, false = off. Default value: false.
public void toggleFlash(Boolean on)
setEnableVibrationOnSuccess
Enable vibration on a successful scan.
@param enabled indicates whether the vibration feature is enabled. Default value: true.
public static void setEnableVibrationOnSuccess(boolean enabled)
setContinuousScanningEnabled
Continuous scanning. If enabled, after a successful scan, the scanner view will not be paused.
See setIgnoreDuplicates for further continuous scanning behavior changes.
@param enabled indicates whether the scanner should stay active after a successful scan. Default value: false.
public void setContinuousScanningEnabled(boolean enabled)
setIgnoreDuplicates
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)
Updated Jun 18, 2024 · Questions? Ask us