Generic Document Recognizer | React Native Generic Document Recognizer
Generic Document Recognizer
ScanbotSdk.UI.startGenericDocumentRecognizer(configuration: GenericDocumentRecognizerConfiguration): Promise
The Scanbot SDK provides the ability to detect various types of documents in an image, crop them and recognize data fields via the Generic Document Recognizer.
Currently, the Generic Document Recognizer supports the following types of documents:
- German ID Card
- German Passport
- German Driver's license
The Generic Document Recognizer is based on the OCR feature and thus requires the proper installation of the OCR language files deu.traineddata
and eng.traineddata
(aka. blob files).
For more details on how to set up OCR language files please refer to the OCR section.
Use the API method ScanbotSdk.UI.startGenericDocumentRecognizer(configuration: GenericDocumentRecognizerConfiguration): Promise<ResultWrapper<GenericDocumentRecognizerResult>>
to start the Generic Document Recognizer Ready-To-Use UI.
Result:
The promise resolves to a result object with the following type:
export interface GenericDocumentRecognizerResult {
documents: Array<
| MRZDocument
| DeIdCardFrontDocument
| DeIdCardBackDocument
| DePassportDocument
| DeDriverLicenseFrontDocument
| DeDriverLicenseBackDocument
>;
}
Document Type:
The document type can be one of the following:
export type GenericDocumentType =
/** German ID card, front side */
| 'DeIdCardFront'
/** German ID card, back side */
| 'DeIdCardBack'
/** German travel passport (Reisepass) */
| 'DePassport'
/** German driver license (Führerschein), front side */
| 'DeDriverLicenseFront'
/** German driver license (Führerschein), back side */
| 'DeDriverLicenseBack';
Configuration
To only recognize a specific type of document, you can use the acceptedDocumentTypes
property.
For example, if you only want to recognize German ID Cards, you can use the following configuration:
let config: GenericDocumentRecognizerConfiguration = {
// Enables recognition for german ID cards only (front and back)
acceptedDocumentTypes: ['DE_ID_CARD_FRONT', 'DE_ID_CARD_BACK']
}
Here you can read all the properties available in GenericDocumentRecognizerConfiguration
:
All configuration options are optional.
export interface GenericDocumentRecognizerConfiguration {
/** Controls whether the flash should be initially enabled. The default value is FALSE. */
flashEnabled?: boolean;
/** UI Interface orientation lock mode */
orientationLockMode?: OrientationLockMode;
/** The preferred camera module (default - BACK) */
cameraModule?: CameraModule;
/** The background color of the top toolbar. */
topBarBackgroundColor?: string;
/** The color of all active toggle buttons in the toolbar. */
topBarButtonsActiveColor?: string;
/** The color of all inactive toggle buttons in the toolbar. */
topBarButtonsInactiveColor?: string;
/** Background color outside of the finder window. */
cameraOverlayColor?: string;
/** Foreground color of the detection overlay. */
finderLineColor?: string;
/** Width of finder frame border. Default is 2. */
finderLineWidth?: number;
/** Text color of the fields count label. */
fieldsCountTextColor?: string;
/** Color of confidence value label background in details screen, when the field confidence level is high. */
fieldConfidenceHighColor?: string;
/** Color of confidence value label background in details screen, when the field confidence level is moderate. */
fieldConfidenceModerateColor?: string;
/** Color of confidence value label background in details screen, when the field confidence level is low. */
fieldConfidenceLowColor?: string;
/** Color of confidence value label text in details. */
fieldConfidenceTextColor?: string;
/** Color of tip text on scanning screen. */
tipTextColor?: string;
/** Color of tip background on scanning screen. */
tipBackgroundColor?: string;
/** The color of bottom sheet */
detailsBackgroundColor?: string;
/** The color of text elements in bottom sheet */
detailsPrimaryColor?: string;
/** The color of Submit button */
detailsActionColor?: string;
/** Text color for section headers on the details screen. iOS only. */
detailsSectionHeaderTextColor?: string;
/** Background color for section headers on the details screen. iOS only. */
detailsSectionHeaderBackgroundColor?: string;
/** Title of the cancel button. */
cancelButtonTitle?: string;
/** Whether the cancel button is hidden or not. iOS only. */
cancelButtonHidden?: boolean;
/** String used for displaying amount of detected fields. Use %d for number formatting symbol. */
clearButtonTitle?: string;
/** Text of the button which finishes the flow */
submitButtonTitle?: string;
/** String used for displaying amount of detected fields. Use %d for number formatting symbol. */
fieldsCountText?: string;
/** String that shows average confidence value of scanned document. Use %d as number formatting symbol. */
confidenceValue?: string;
/** String that asks user to scan back side of a document. */
scanBackSideTitle?: string;
/** String that asks user to scan front side of a document. */
scanFrontSideTitle?: string;
/** String that asks user to start scanning a document. */
startScanningTitle?: string;
/** String that notifies that both sides of document are scanned. */
scannedEverythingTitle?: string;
/** String being displayed for empty values. iOS only. */
emptyValueTitle?: string;
/** Title of the button that opens the screen where the user can allow the usage of the camera by the app. */
enableCameraButtonTitle?: string;
/** Text that will be displayed when the app is not allowed to use the camera, prompting the user to enable the usage of the camera. */
enableCameraExplanationText?: string;
/** A title to show image content. Android only. */
imageTitle?: string;
/** String that notifies that nothing was scanned yet. */
noDataTitle?: string;
/** Accepted document types. All other document types will be ignored. By default - All types */
acceptedDocumentTypes?: GenericDocumentType[];
/** Accepted minimal sharpness score. Images with a score less than that will be rejected with RecognitionStatus::ErrorTooBlurry. Default is 80. 0 - any image will be accepted. 80 - a good compromise; the recommended setting. 100 - only very sharp images will be accepted. */
sharpnessAcceptanceFactor?: number;
/** Allows to configure the display configuration for fields. */
fieldsDisplayConfiguration?: FieldsDisplayConfiguration[];
/** Allows to configure the display configuration for documents. */
documentsDisplayConfiguration?: DocumentsDisplayConfiguration[];
/** List of secure fields which should be excluded from scanning process. All other fields will be scanned as usual. Field should be set ONLY as normalized field name. Example - [DePassport.BirthDate] or [DePassport.Birthplace] */
excludedFieldTypes?: string[];
/** Controls whether the flash toggle button is hidden or not. */
flashButtonHidden?: boolean;
/** Title of the flash toggle button. */
flashButtonTitle?: string;
/** Controls whether buttons should use all capitals style, as defined by the Android Material Design. Defaults to TRUE. Android only. */
useButtonsAllCaps?: boolean;
/** If `true`, replaces the cancel button in the top bar with a back arrow icon. The default value is FALSE. Android only. */
replaceCancelButtonWithIcon?: boolean;
/** Preview mode of the camera. FILL_IN or FIT_IN. Default is FILL_IN. Android only */
cameraPreviewMode?: CameraPreviewMode;
/** Whether touch-to-focus is enabled on camera preview. Enabled by default. Android only. */
touchToFocusEnabled?: boolean;
}
Available documents and fields
DeDriverLicenseBack
DeDriverLicenseBack.Restrictions
DeDriverLicenseBack.Category.Restrictions
DeDriverLicenseBack.Category.ValidFrom
DeDriverLicenseBack.Category.ValidUntil
DeDriverLicenseFront
DeDriverLicenseFront.BirthDate
DeDriverLicenseFront.Birthplace
DeDriverLicenseFront.ExpiryDate
DeDriverLicenseFront.GivenNames
DeDriverLicenseFront.ID
DeDriverLicenseFront.IssueDate
DeDriverLicenseFront.IssuingAuthority
DeDriverLicenseFront.LicenseCategories
DeDriverLicenseFront.Photo
DeDriverLicenseFront.Signature
DeDriverLicenseFront.Surname
DeIdCardBack
DeIdCardBack.Address
DeIdCardBack.EyeColor
DeIdCardBack.Height
DeIdCardBack.IssueDate
DeIdCardBack.IssuingAuthority
DeIdCardBack.Pseudonym
DeIdCardBack.RawMRZ
DeIdCardBack.MRZ.${MRZ_FIELD_NAME}
- (check MRZ field names below)
DeIdCardFront
DeIdCardFront.BirthDate
DeIdCardFront.Birthplace
DeIdCardFront.ExpiryDate
DeIdCardFront.GivenNames
DeIdCardFront.ID
DeIdCardFront.MaidenName
DeIdCardFront.Nationality
DeIdCardFront.PIN
DeIdCardFront.Photo
DeIdCardFront.Signature
DeIdCardFront.Surname
DePassport
DePassport.BirthDate
DePassport.Birthplace
DePassport.CountryCode
DePassport.ExpiryDate
DePassport.Gender
DePassport.GivenNames
DePassport.ID
DePassport.IssueDate
DePassport.IssuingAuthority
DePassport.MaidenName
DePassport.Nationality
DePassport.PassportType
DePassport.Photo
DePassport.RawMRZ
DePassport.Signature
DePassport.Surname
DePassport.MRZ.${MRZ_FIELD_NAME}
- (check MRZ field names below)
MRZ Field Names
${DOCUMENT_NAME}.MRZ.BirthDate
${DOCUMENT_NAME}.MRZ.CheckDigit
${DOCUMENT_NAME}.MRZ.DocumentNumber
${DOCUMENT_NAME}.MRZ.ExpiryDate
${DOCUMENT_NAME}.MRZ.Gender
${DOCUMENT_NAME}.MRZ.GivenNames
${DOCUMENT_NAME}.MRZ.IssuingAuthority
${DOCUMENT_NAME}.MRZ.Nationality
${DOCUMENT_NAME}.MRZ.Optional1
${DOCUMENT_NAME}.MRZ.Optional2
${DOCUMENT_NAME}.MRZ.Surname
${DOCUMENT_NAME}.MRZ.TravelDocType
${DOCUMENT_NAME}.MRZ.TravelDocTypeVariant
Want to scan longer than one minute?
Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.