Skip to main content

Generic Document Scanner | Flutter Document Scanner

Introduction

The Scanbot SDK comes with an essential camera view, additional views for extending the camera functionality and a detector classes that handle all the camera and detection implementation details for you.

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 scanner is available both as an RTU-UI Component (types of components are explained here).

Take a look at our Example Apps to see how to integrate the Generic Documents Scanner.

Generic Document Scanner RTU-UI Component

alt

ScanbotSdkUi.startGenericDocumentRecognizer(config)


var config = GenericDocumentRecognizerConfiguration(
acceptedDocumentTypes: [
GenericDocumentType.DE_DRIVER_LICENSE_FRONT,
GenericDocumentType.DE_DRIVER_LICENSE_BACK,
GenericDocumentType.DE_ID_CARD_FRONT,
GenericDocumentType.DE_ID_CARD_BACK,
GenericDocumentType.DE_PASSPORT,
],
cameraOverlayColor: Colors.black.withAlpha(150),
topBarBackgroundColor: Colors.red,
fieldConfidenceLowColor: Colors.blue,
fieldConfidenceHighColor: Colors.purpleAccent,
fieldsDisplayConfiguration: [
// All types of documents have its own class for field signatures, e.g. DeIdCardFront -> DeIdCardFrontFieldsSignatures. From this classes you can take field signatures for each field you want to configure.
FieldsDisplayConfiguration(DeIdCardFrontFieldsSignatures.Surname, "My Surname", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardFrontFieldsSignatures.GivenNames, "My GivenNames", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardFrontFieldsSignatures.BirthDate, "My Birth Date", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardFrontFieldsSignatures.ExpiryDate, "Document Expiry Date", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardBackFieldsSignatures.Address, "My address", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardBackFieldsSignatures.IssueDate, "When issued", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(DeIdCardBackFieldsSignatures.IssuingAuthority, "Who issued", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(MRZFieldsSignatures.DocumentNumber, "My Doc Num", FieldDisplayState.ALWAYS_VISIBLE),
FieldsDisplayConfiguration(MRZFieldsSignatures.Surname, "My Surname", FieldDisplayState.ALWAYS_VISIBLE),
],
documentsDisplayConfiguration: [
DocumentsDisplayConfiguration(DeIdCardBack.DOCUMENT_NORMALIZED_TYPE, "Id Card Back Side"),
DocumentsDisplayConfiguration(MRZ.DOCUMENT_NORMALIZED_TYPE, "MRZ on document back"),
DocumentsDisplayConfiguration(DeDriverLicenseFront.DOCUMENT_NORMALIZED_TYPE, "Licence plate Front"),
DocumentsDisplayConfiguration(DeDriverLicenseBack.DOCUMENT_NORMALIZED_TYPE, "Licence plate Back"),
]
);
result = await ScanbotSdkUi.startGenericDocumentRecognizer(config);

if (result.operationResult == OperationResult.SUCCESS) {
// see the array `result.documents`
for (var document in result.documents) {
switch (document.documentType) {
case DocumentType.MRZ:
return MrzView(document as MRZ);
case DocumentType.DeIdCardFront:
return DeIdCardFrontView(document as DeIdCardFront);
case DocumentType.DeIdCardBack:
return DeIdCardBackView(document as DeIdCardBack);
case DocumentType.DePassport:
return DePassportView(document as DePassport);
case DocumentType.DeDriverLicenseFront:
return DeDriverLicenseFrontView(document as DeDriverLicenseFront);
case DocumentType.DeDriverLicenseBack:
return DeDriverLicenseBackView(document as DeDriverLicenseBack);
default:
return Container();
}
}

}
  • status:
    • 'OK' if data was extracted,
    • 'CANCELED' if the user canceled the operation (tapped on the "cancel" button).
  • documentType: GenericDocumentType may be one of the following document types 'DeDriverLicense', 'DePassport', 'DeIdCard'
  • fields: GenericDocumentFields An object with extracted data fields.
GenericDocumentRecognizerConfiguration

All UI configuration options are optional.

  /// A version of the configuration object
String? version;

/// The configuration object should be applied for this screen
String? screen;

/// Controls whether the flash should be initially enabled. The default value is FALSE.
bool? flashEnabled;

/// UI Interface orientation lock mode
OrientationLockMode? orientationLockMode;

/// The preferred camera module (default - BACK)
CameraModule? cameraModule;

/// The background color of the top toolbar.
Color? topBarBackgroundColor;

/// The color of all active toggle buttons in the toolbar.
Color? topBarButtonsActiveColor;

/// The color of all inactive toggle buttons in the toolbar.
Color? topBarButtonsInactiveColor;

/// Background color outside of the finder window.
Color? cameraOverlayColor;

/// Foreground color of the detection overlay.
Color? finderLineColor;

/// Width of finder frame border. Default is 2.
double? finderLineWidth;

/// Text color of the fields count label.
Color? fieldsCountTextColor;

/// Color of confidence value label background in details screen, when the field confidence level is high.
Color? fieldConfidenceHighColor;

/// Color of confidence value label background in details screen, when the field confidence level is moderate.
Color? fieldConfidenceModerateColor;

/// Color of confidence value label background in details screen, when the field confidence level is low.
Color? fieldConfidenceLowColor;

/// Color of confidence value label text in details.
Color? fieldConfidenceTextColor;

/// Color of tip text on scanning screen.
Color? tipTextColor;

/// Color of tip background on scanning screen.
Color? tipBackgroundColor;

/// The color of bottom sheet
Color? detailsBackgroundColor;

/// The color of text elements in bottom sheet
Color? detailsPrimaryColor;

/// The color of Submit button
Color? detailsActionColor;

/// Text color for section headers on the details screen. iOS only.
Color? detailsSectionHeaderTextColor;

/// Background color for section headers on the details screen. iOS only.
Color? detailsSectionHeaderBackgroundColor;

/// Title of the cancel button.
String? cancelButtonTitle;

/// Whether the cancel button is hidden or not. iOS only.
bool? cancelButtonHidden;

/// String used for displaying amount of detected fields. Use %d for number formatting symbol.
String? clearButtonTitle;

/// Text of the button which finishes the flow
String? submitButtonTitle;

/// String used for displaying amount of detected fields. Use %d for number formatting symbol.
String? fieldsCountText;

/// String that shows average confidence value of scanned document. Use %d as number formatting symbol.
String? confidenceValue;

/// String that asks user to scan back side of a document.
String? scanBackSideTitle;

/// String that asks user to scan front side of a document.
String? scanFrontSideTitle;

/// String that asks user to start scanning a document.
String? startScanningTitle;

/// String that notifies that both sides of document are scanned.
String? scannedEverythingTitle;

/// String being displayed for empty values. iOS only.
String? emptyValueTitle;

/// Title of the button that opens the screen where the user can allow the usage of the camera by the app.
String? enableCameraButtonTitle;

/// 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.
String? enableCameraExplanationText;

/// A title to show image content. Android only.
String? imageTitle;

/// String that notifies that nothing was scanned yet.
String? noDataTitle;

/// Accepted document types. All other document types will be ignored. By default - All types
List<GenericDocumentType>? acceptedDocumentTypes;

/// 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.
double? sharpnessAcceptanceFactor;

/// Allows to configure the display configuration for fields.
List<FieldsDisplayConfiguration>? fieldsDisplayConfiguration;

/// Allows to configure the display configuration for documents.
List<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]
List<String>? excludedFieldTypes;

/// Controls whether the flash toggle button is hidden or not.
bool? flashButtonHidden;

/// Title of the flash toggle button.
String? flashButtonTitle;

/// Controls whether buttons should use all capitals style, as defined by the Android Material Design. Defaults to TRUE. Android only.
bool? useButtonsAllCaps;

/// If `true`, replaces the cancel button in the top bar with a back arrow icon. The default value is FALSE. Android only.
bool? replaceCancelButtonWithIcon;

/// 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.
bool? touchToFocusEnabled;

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 License

What do you think of this documentation?