smaatsdk - serimag · release v1.0 example of folders and files necessary for document capture the...

31
SMAATSDK INTELLIGENTSCANNER MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0

Upload: others

Post on 06-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

SMAATSDK

INTELLIGENTSCANNER MODULE ON ANDROID

REQUIREMENTS AND DOCUMENTATION

RELEASE v1.0

Page 2: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

Requisitos y documentación del Módulo IntelligentScanner en Android Release v1.0

Table of contentsScope....................................................................................................3Purpose..................................................................................................3General operating diagram...........................................................................4Example of folders and files necessary for document capture.................................5Minimum requirements for the operation of the SDK............................................6Recommended requirements for the operating of the SDK.....................................6Functions provided and parameters to use them.................................................6

Functions necessary for document capture....................................................6Connection with post-processing functions.....................................................8Functions for text extraction with OCR.........................................................9Optional functions for document capture......................................................9Functions necessary for capturing barcodes..................................................10Optional functions for barcode capture.......................................................11Common optional functions.....................................................................12Parameters to use.................................................................................13Diagrama de las funcionalidades................................................................18

Usage example........................................................................................19Example of default capture configuration....................................................19Example of personalised capture configuration..............................................23

Appendices............................................................................................28Use of the capture screen.......................................................................28

Documents (ID, Residence Cards, Passports, Cheques and Cards)......................28Barcodes.........................................................................................30

Recommendations for capture..................................................................31

Page 3: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

ScopeThis document contains a detailed explanation of the functionalities and requirements of the SDKIntelligentScanner. To start with, a general operating diagram is provided and the files required fordocument capture are explained, as well as all the steps that must be taken for their filing. Next, theminimum requirements for the correct operation of the SDK are described, as well as those recommendedby Serimag. Finally, all the functions provided and their parameters are described, together with an exampleof their use. The usage example has two configurations: default and personalised.

PurposeThe purpose of this document is to explain the operation and requirements of the IntelligentScannerModule in detail, and to facilitate its integration into new and already existing projects.

04/04/2018 3/31

Page 4: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

General operating diagram

04/04/2018 4/31

Application blocks

Blocks encapsulated by the SDK

Capture engine blocks

Barcode reader library blocks

OCR engine blocks

Requests captureand extraction

data

Returnscontrol

Opens capturescreen for barcodes

Opens capturescreen

Capturesdocument

Savescapture

Returns text with thecaptured barcode

Stops capture

Requests barcode data

OCR extraction

Returnsextracted

text

Page 5: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains three foldersnecessary for the operation of the SDK:

Captures:

• This folder contains the captures made by the engine.

Config

• The engine.cfg configuration file is saved in this folder.

Models:

• This folder contains the classification models for the different documents to be detected. In thiscase, ES_ID_FRONT, ES_ID_BACK, ES_ID_23, ES_RESIDENCE_FRONT, ES_RESIDENCE_BACK andEU_CHECK_FRONT. It also contains the tessdata folder which must also contain the mrz.traineddatamodel.

04/04/2018 5/31

Page 6: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Minimum requirements for the operation of the SDK• Android 5.0 (API 21) or later

• Device with rear camera

• Device with preview resolution equal to or greater than 1280 x 720.

• 100MB of RAM available

• Approximately 2.5 MB of disk space available for the capture of 10 documents.

• Approximately 10 MB of disk space available for the installation of the application related to theSDK.

• Sufficient space on disk to store the different models.

• 1.2 GHz Dual-Core Processor.

Recommended requirements for the operating of the SDK• Android 5.0 or later

• Device with rear camera.

• Device with preview resolution equal to or greater than 1920 x 1080.

• 100 MB of RAM available.

• Approximately 5MB of disk space available for the capture of 10 documents.

• Approximately 10 MB of disk space available for the installation of the application related to theSDK.

• Sufficient space on disk to store the different models.

• 1.2 GHz Quad-Core Processor

Functions provided and parameters to use them

Functions necessary for document capture

Functions necessary for document capture (ID, RESIDENCE CARD, PASSPORT , CHECK, CARD)These functions are defined in the IntelligentScannerInterface.java file

IntelligentScannerInterface intelligentScanner = IntelligentScannerInterface.getInstance()

Assigns the instance of the processing engine. Theinstance of this object follows the Singleton pattern.

void intelligentScanner.setModelPath(String modelPath)

Sets the Models folder path (where the models are), sothey can be subsequently loaded into the memory.

04/04/2018 6/31

Page 7: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

void intelligentScanner.setConfigPath(String ConfigPath)

Sets the Config folder path, where the “engine.cfg”configuration file is located.

Exceptions:

• Exception

void intelligentScanner.setCapturePath(String CapturePath)

Sets the Captures folder path, where the capturesmade are located.

void intelligentScanner.loadModel(String documentType)

Loads models into memory.

Exceptions:

• EngineModelNotFound• ConfigFileNotFound• ConfigFileMalformatted• DocumentTypeNotDefined• Exception

boolean intelligentScanner.checkIfModelLoaded(String documentType)

Checks if the specified document model is correctlyloaded.

Exceptions:• EngineModelNotLoaded

Return:

• True → Archivo cargado• False → Archivo NO cargado

void intelligentScanner.useEngine(String documentType)

Assigns the document model to the engine

Exceptions:

• EngineModelNotLoadedBefore use:

• Check that the model is loaded using thecheckIfModelLoaded() function.

*Add optional functions and connection with post-processing functions

void intelligentScanner.runScanner(String documentType, Activity activity, int requestCode)

Starts the capture screen. **

Exceptions:

• EngineModelNotLoaded• EngineModelNotFound

Before use:

• Be sure to assign the document model to theengine with useEngine()

04/04/2018 7/31

Page 8: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

String getCaptureName() Gets the name (including extension) of the last captureof the running of the intelligentScanner.runScanner()method;

Return:

• String with name and extension if capturemade.

• String empty if no capture made.

Exceptions:

• Exception

void intelligentScanner.unloadModel(String documentType)

Deletes the specified model from the memory.

Exceptions:

• EngineModelNotFound

Before use:

• Be sure to assign the document model to theengine with useEngine()

Connection with post-processing functions

*Connection with post-processing functionsThese functions generate the image to post-process

void intelligentScanner.generatePostProcessImage(boolean generatePostProcessImageFlag)

Generates the image that will be sent as an input tothe post-processing model

• True → enable• False → disable

String intelligentScanner.getPostProcessImageName()

Gets the name (including extension) of the lasttemporary capture that can be sent to post-processing.

Return:

• String with name and extension if capturemade.

• String empty if the image to post-process wasnot saved with thegeneratePostProcessImage() function;

Exceptions:

• Exception

04/04/2018 8/31

Page 9: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Functions for text extraction with OCR

*Functions for text extraction with OCR

void intelligentScanner.loadOcrEngine() Creates the text extraction with OCR engine.

void intelligentScanner.useOcrEngine(String documentType)

Loads the model into memory.

Exceptions:

• EngineModelNotFound• DocumentTypeNotDefined

void intelligentScanner.setOcrParameters(int timerFinishOCR)

Allows parametrisation of the timer that returnscontrol of the application, in case it has not beenpossible to extract the text with OCR.

JSONObject intelligentScanner.getMrzData() Returns data extracted with OCR from the document. Within the set of data, a distinction is made between:

• “name”• “surname”• “optionalData”• “birthDate”• “gender”• “nationality”• “expiryDate”• “documentType”• “isssuingState”• “documentNumber”

Exceptions:• JSONException

Optional functions for document capture

*Optional functions

These functions can be used to change the capture properties. Before using them, ensure that thedocument model is assigned to the engine.

void intelligentScanner.setImageQuality(int width, int height, int quality)

Sets properties (width, height, quality) of theprocessed image.

04/04/2018 9/31

Page 10: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

void intelligentScanner.setCaptureName(String name)

Sets the name of the processed image. If thegeneration of the image to post-process is enabledthrough generatePostProcessImage(), the secondimage will be generated with the same set name andthe “_temp” suffix.

void intelligentScanner.aggressiveCapture(boolean aggressiveCapture)

Sets aggressive capture mode (without safety edges) ornormal (with safety edges).

• True → Aggressive• False → Normal

void intelligentScanner.enableFocusFilter() Enables the focus filter.

void intelligentScanner.disableFocusFilter() Disables the focus filter.

void intelligentScanner.enableTemplate(int templateColor)

Enables the camera preview template. Allowsparametrisation of the template colour.

void intelligentScanner.disableTemplate() Disables the camera preview template.

void enableFeatures(int featuresColor) Enables display of features corresponding to theextraction of characteristics in the preview. Allowsparametrisation of the feature colours.

void disableFeatures() Disables the display of the features corresponding tothe extraction of characteristics in the preview.

boolean intelligentScanner isDNI3() Checks if the FRONT of a captured Spanish ID is version2.0 or 3.0. This function returns:

• True → ID 3.0• False → ID 2.0

void intelligentScanner.cleanCapturesFolder() Clears all the content of the "Captures" folder from thedevice memory.

Exceptions:

• Exception

Functions necessary for capturing barcodes

*Functions necessary for capturing barcodesThese functions are essential for reading barcodes

void intelligentScanner.useEngine(String documentType)

Assigns the document model to the engine

Exceptions:• EngineModelNotLoaded

04/04/2018 10/31

Page 11: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

void intelligentScanner.runScanner(String documentType, Activity activity, int intentResult)

Starts the capture screen.

Exceptions:

• EngineModelNotLoadedBefore use:

• Be sure to assign the document model to theengine with useEngine()

String intelligentScanner.getBarcodeResult() Returns the read barcode in String format.

void intelligentScanner.disableBarcodeAnimation( BarcodeType barcodeType)

Disables the animation of the line in the camerapreview.

Optional functions for barcode capture

*Optional functions for barcode captureThese functions can be used for barcode capture

void intelligentScanner.enableBarcodeAnimation(BarcodeType barcodeType)

Enables the animation of the line in the camerapreview.

void intelligentScanner.enableBarcodeBackground( BarcodeType barcodeType)

Enables the dark shading outside the barcode capturearea.

void intelligentScanner.disableBarcodeBackground(BarcodeType barcodeType)

Disables the dark shading outside the barcode capturearea.

void intelligentScanner.enableBarcodeTemplate( BarcodeType barcodeType, int barcodeTemplateColor)

Enables the barcode template in the camera preview.

void intelligentScanner.disableBarcodeTemplate(BarcodeType barcodeType)

Disables the barcode template in the camera preview.

String getBarcodeFormat() Returns a String with the barcode format.

04/04/2018 11/31

Page 12: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Common optional functions

*Common optional functionsThese are common functions for both document capture and barcode capture.

void intelligentScanner.setFocusParameters(int timerSwitchFocus, int timerAutofocus)

Controls the camera focus. Allows parametrisation ofthe time that elapses until the camera autofocus ischanged to the controlled autofocus. Once theautofocus of the camera is disabled, it also allows toparametrize how often the camera must focus. Thisfunction is used due to the fact that in some devicesthe camera does not stop focusing, and this makesdocument capture difficult.

void intelligentScanner.setTextToScreen(String textToScreen)

Text to display on the capture screen.

void intelligentScanner.enableCaptureAdvice( int adviceBackgroundColor, int adviceTextColor, int timeoutAdviceText, int timeoutForceCapture, int timeoutExitCamera)

Enables a warning message if no capture is made.Allows parametrisation of the message colour andbackground on which the text is written. It alsoparametrises the timeout for enabling the message,and the timeout for enabling the capture withoutmodel validation, as well as the timeout for return ofcamera control if capture by using the capture withoutmodel validation has not been possible.

void intelligentScanner.setAdviceTextToScreen(String adviceTextToScreen)

Text displayed as advice if capture not made. Theadvice is shown on the screen after thetimeoutAdviceText for the enableCaptureAdvice()function has elapsed, and until control of the camera isreturned.

EXAMPLE:

"Advice: slide the exposure bar to improve thecapture!"

void intelligentScanner.setDocumentNameTextToScreen(String documentNameTextToScreen, int documentNameColor)

Allows the String with the name of the document thatyou wish to capture to be displayed on the screen. Italso allows the text colour to be parametrised.

void intelligentScanner.enableBrightnessBar(int brightnessBarColor, brightnessBarCircleColor)

Enables the brightness bar. It also enables theanimation that indicates the use of the brightness baronce the timeoutAdviceText for theenableCaptureAdvice() function has ended.

04/04/2018 12/31

Page 13: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

void intellgentScanner. disableBrightnessBar() Disables the brightness bar. It also disables theanimation that indicates the use of the brightness baronce the timeoutAdviceText for theenableCaptureAdvice() function has ended.

boolean intelligentScanner.getDocumentVerified()

Checks whether the document has been captured byusing the capture model or by using the capturewithout model validation. This function returns:

• True → Normal capture • False → Capture without model validation

boolean intelligentScanner.getBackButtonPressed()

Checks whether control has been returned to theapplication due to the user pressing the "Back" button.This function returns:

• True → “Back” pressed• False → “Back” not pressed

Parameters to use

Parameters to use

Parameters to use in the above functions

String modelPath This parameter specifies the path to the "Model"folder.

String configPath This parameter specifies the path to the "Config"folder.

String capturePath This parameter specifies the path to the "Capture"folder.

String documentType This parameter can take seven values that correspondto the names of the documents to be captured:

• ES_ID_FRONT• ES_ID_BACK• ES_RESIDENCE_FRONT• ES_RESIDENCE_BACK• INT_PASSPORT• EU_CHECK_FRONT• STANDARD_CARD

In the case of barcode capture, this parameter willhave the following value:

• BARCODE

04/04/2018 13/31

Page 14: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

int requestCode It is the requestCode for getting the result of thestartActivityForResult().

String text This parameter can contain any character accepted bya string variable with a maximum of 60 characters. Thisparameter is an empty string by default.

String adviceTextToScreen This parameter can contain any character accepted bya string variable with a maximum of 60 characters. Thisparameter is an empty string by default.

String documentNameTextToScreen This parameter can contain any character accepted bya string variable with a maximum of 60 characters. Thisparameter is an empty string by default.

int adviceBackgroundColor This parameter specifies the background of thewarning message, as well as the colour of the arrowsthat indicate the use of the exposure bar. Thisparameter is an int as the return of the Color class is anint.

int adviceTextColor This parameter specifies the colour of the warningmessage text. This parameter is an int as the return ofthe Color class is an int.

int dcumentNameColor This parameter specifies the colour of thedocumentNameTextToScreen text. This parameter isan int as the return of the Color class is an int.

int templateColor This parameter specifies the colour of the templatethat is displayed on the camera preview. Thisparameter is an int as the return of the Color class isan int

int featuresColor This parameter specifies the colour of the features thatare displayed on the camera preview.

int brightnessBarColor This parameter specifies the colour of the brightnessbar. This parameter is an int as the return of the Colorclass is an int.

int brightnessBarCircleColor This parameter specifies the colour of the brightnessbar circle. This parameter is an int as the return of theColor class is an int.

04/04/2018 14/31

Page 15: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

int timerSwitchFocus This parameter specifies the time that elapses fromwhen the camera is enabled until the autofocus isdisabled and replaced by a controlled focus. The timeis measured in seconds and its default value is 5seconds.

int timerAutofocus This parameter specifies how often the camera mustfocus once the autofocus is disabled. The time ismeasured in seconds and its default value is 2 seconds.

int timeoutAdviceText This parameter specifies the time that elapses fromwhen the camera is enabled until the warning messageappears. The time is measured in seconds and itsdefault value is 10 seconds.

int timeoutForceCapture This parameter specifies the time that elapses fromwhen the warning message is enabled until thedocument model validation is disabled. Its defaultvalue is 10 seconds.

int timeoutExitCamera This parameter specifies the time that elapses fromwhen the capture without model validation is enabledand camera control is returned because capture wasnot possible. Its default value is 20 seconds.

int timerFinishOCR This parameter specifies the time that elapses fromwhen the document is captured until the cameracontrol is returned due to text extraction with OCR notbeing possible.Its default value is 20 seconds.

String name This parameter can contain any character accepted bya String variable. By default, this parameter containsthe time stamp of the moment at which the capture isstarted.

04/04/2018 15/31

Page 16: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

int width This parameter specifies the width of the capture inpixels.

• Minimum size permitted: 1 pixel

• Maximum size permitted: ∞ pixels

• Default size onID/RESIDENCE/STANDARD_CARD: 670 pixels

• Recommended size onID/RESIDENCE/STANDARD_CARD: 670 pixels

• Default size on INT_PASSPORT: 674 pixels

• Recommended size on INT_PASSPORT: 674pixels

• Default size on EU_CHECK: 692 pixels

• Recommended size on EU_CHECK: 692 pixels

int height This parameter specifies the height of the capture inpixels.

• Minimum size permitted: 1 pixel

• Maximum size permitted: ∞ pixels

• Default size onID/RESIDENCE/STANDARD_CARD: 425 pixels

• Recommended size onID/RESIDENCE/STANDARD_CARD: 425 pixels

• Default size on INT_PASSPORT: 475 pixels

• Recommended size on INT_PASSPORT: 475pixels

• Default size on EU_CHECK: 315 pixels

• Recommended size on EU_CHECK: 315 pixels

int quality This parameter specifies the quality percentage of thecapture:

• Minimum percentage permitted: 0

• Maximum percentage permitted: 100

• Default percentage on ID, RESIDENCE,STANDARD_CARD, INT_PASSPORT andEU_CHECK 100

• Percentage recommended on ID, RESIDENCE,STANDARD_CARD, INT_PASSPORT andEU_CHECK 100

04/04/2018 16/31

Page 17: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

boolean agressiveCapture The default value of this parameter is FALSE.

boolean generatePostProcessImageFlag The default value of this parameter is FALSE.

BarcodeType barcodeType This parameter specifies the type of barcode that youwish to capture. It can take two values:

• Unidimensional → For 1D codes• Bidimensional → For 2D codes

Access Keys to the JSON

“name” Allows the extraction of the FIRST NAME from theJSONObject that getMrzData() function return.

“surname” Allows the extraction of the SURNAME from theJSONObject that getMrzData() function return.

“optionalData” Allow the extraction of the OPTIONAL DATA fromthe JSONObject that getMrzData() function return.

“birthDate” Allow the extraction of the BIRRTH DATE from theJSONObject that getMrzData() function return.

“gender” Allow the extraction of the GENDER from theJSONObject that getMrzData() function return.

“nationality” Allow the extraction of the NATIONALITY from theJSONObject that getMrzData() function return.

“expiryDate” Allow the extraction of the EXPIRY DATE from theJSONObject that getMrzData() function return.

“documentType” Allow the extraction of the DOCUMENT TYPE fromthe JSONObject that getMrzData() function return.

“issuingState” Allow the extraction of the ISSUING COUNTRY fromthe JSONObject that getMrzData() function return.

“documentNumber” Allow the extraction of the DOCUMENT NUMBERfrom the JSONObject that getMrzData() functionreturn.

04/04/2018 17/31

Page 18: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Diagrama de las funcionalidades

04/04/2018 18/31

Documentcapture Barcodes

Necessary- setModelPath()- setConfigPath()- setCapturePath()- modelo()- checkIfModelLoaded()- useEngine()- runScanner()- getCaptureName()- loadModel()

Connecting with Post-Processing functions- generatePostProcessImage()- getPostProcessImageName()

Functions for text extraction with OCR- loadOcrEngine()- useOcrEngine()- setOcrParameters()- getMrzData() Optional functions- setImageQuality() - setCaptureName()- aggressiveCapture() - enableFocusFilter()- disableFocusFilter() - enableTemplate()- disableTemplate() - enableFeatures()- disableFeatures()- isDNI3() - cleanCaptureFolder()

Necessary functions

- useEngine() - disableBarcodeAnimation() - runScanner() - getBarcodeResult()

Optional functions

- enableBarcodeAnimation() - enableBarcodeBackground()- disableBarcodeBackground()- enableBarcodeTemplate() - disableBarcodeTemplate() - getBarcodeFormat()

Common optional functions

- setFocusParameters()- setTextToScreen()- enableCaptureAdvice()- enableBrightnessBar()- disableBrightnessBar()- setDocumentNameTextToScreen()- setAdviceTextToScreen()- getDocumentVerified()- getBackButtonPressed()

IntelligentScanner

Page 19: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Usage exampleOnce the AAR IntelligentScanner is installed, we can start to use it.

Example of default capture configurationSuppose that you wanted to create an automatic capture application for backs of IDs and one-dimensionalbarcodes, with a very simple interface. The following screen could be the main screen:

On starting the application, the paths are assigned and the model capable of capturing ID backs is loaded.Once the model is loaded, press the "CAPTURE BACK ID" button on the screen to verify that the model hasbeen loaded correctly. The use of the model is then assigned to the engine and the automatic ID backcapture screen is launched. After capturing an ID, the application goes back to displaying the menu in theprevious image, where the name of the capture can be displayed on the screen. The "EMPTY CAPTURESFOLDER" button can be used to delete all the files in the Captures folder. The "CAPTURE BARCODE" buttoncan also be used for capturing one-dimensional barcodes in this case". If you do not want to change thecapture properties offered by default, the implemented code would be the following:

04/04/2018 19/31

Page 20: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

04/04/2018 20/31

package serimagmedia.capturaautomatica;

import android.content.Manifest;import android.content.Intent;import android.graphics.Color;import android.os.Bundle;import android.os.Environment;import android.support.v7.app.AppCompatActivity;import android.util.Log;import android.view.View;import android.widget.TextView;import org.json.JSONException;import org.json.JSONObject;import java.io.File;import automaticdocumentcapturesdk.IntelligentScannerInterface;

public class StartMenu extends AppCompatActivity {

private File path_sd = Environment.getExternalStorageDirectory(); private File path_models = new File(path_sd.getAbsolutePath() + "//IntelligentScanner//Models"); private File path_captures = new File(path_sd.getAbsolutePath() + "//IntelligentScanner//Captures"); private File path_config = new File(path_sd.getAbsolutePath() + "//IntelligentScanner//Config"); public static IntelligentScannerInterface intelligentScanner; static final int PERMISSION_REQUEST = 1; TextView textView;

public StartMenu(){ }

@Override protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState); setContentView(R.layout.activity_start_menu);

requestPermissions(); textView = (TextView) findViewById(R.id.idTextView1); }

01:02:03:04:05:06:07:08:09:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:

Page 21: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

04/04/2018 21/31

public void initSMAAT_SDK(){ intelligentScanner = IntelligentScannerInterface.getInstance(); intelligentScanner.setConfigPath(path_config.getPath()); intelligentScanner.setModelPath(path_models.getPath()); intelligentScanner.setCapturePath(path_captures.getPath()); }

public void requestPermissions(){ ActivityCompat.requestPermissions(this, new String[]{

// Only if you implement the example using external //storage (SD)

Manifest.permission.WRITE_EXTERNAL_STORAGE,

// Mandatory SDK permissions Manifest.permission.CAMERA,

},PERMISSION_REQUEST); }

public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case PERMISSION_REQUEST: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] ==

PackageManager.PERMISSION_GRANTED && grantResults[1] ==

PackageManager.PERMISSION_GRANTED) {

// Initialize SDK only if permissions are granted initSMAAT_SDK();

} return; } } }

43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:

Page 22: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

04/04/2018 22/31

public void onClickId(View v){

intelligentScanner.loadModel("ES_ID_BACK"); if(intelligentScanner.checkIfModelLoaded("ES_ID_BACK")){ intelligentScanner.useEngine("ES_ID_BACK"); intelligentScanner.runScanner("ES_ID_BACK", this,5002); } }

public void onClickCB(View V){

intelligentScanner.useEngine("BARCODE"); intelligentScanner.runScanner("BARCODE",this, 6001);

}

protected void onActivityResult(int requestCode, int resultCode, Intent intentData){

if(requestCode == 5002){ textView.setText("Capture name: " +

intelligentScanner.getCaptureName()); } else if(requestCode == 6001) { textView.setText("Result: " +

intelligentScanner.getBarcodeResult()); } }

public void onClickEmpty(View v){

intelligentScanner.cleanCapturesFolder(); }

}

83:84:85:86:87:88:89:90: 91:92:93:94:95:96:97:98:99:100:101:102:103:104:105:106:107:108:109:110:111:112:113:114:115:116:117:

Page 23: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Example of personalised capture configuration

Using the same example, in this case we want to change the properties of the captured image. To do this,we can enable the following options:

• Load the OCR text extraction engine in the memory

• Enable the focus control

• Enable the brightness bar and arrow animation

• Set the text to display on the screen while the capture is being carried out

• Set the text that will be displayed as a warning message if the capture is not carried out

• Set the text to display on the screen with the name of the document to be captured

• Enable the preview template

• Enable the preview features

• Enable the focus filter

• Set the size and quality of the output image

• Enable aggressive capture

• Set the name of the captured image

• Load the OCR text extraction models in the memory

• Set the parameters for the OCR text extraction

• Enable the function that will generate the image to be sent to the post-processing module

• Enable the function that will display the warning message

• Enable the function that will verify the capture

• Enable the function that will verify the way in which application control is returned

• Enable the function that will verify if the back of the captured ID is 2.0 or 3.0.

The implemented code on pressing the capture button would be the following:

04/04/2018 23/31

public void initSMAAT_SDK(){

intelligentScanner = IntelligentScannerInterface.getInstance(); intelligentScanner.setConfigPath(path_config.getPath()); intelligentScanner.setModelPath(path_models.getPath()); intelligentScanner.setCapturePath(path_captures.getPath());

intelligentScanner.loadOcrEngine(); }

43:44:45:46:47:48:49:50:51:52:

Page 24: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

04/04/2018 24/31

public void onClickId(View v){

intelligentScanner.loadModel("ES_ID_BACK");

if(intelligentScanner.checkIfModelLoaded("ES_ID_BACK")){ intelligentScanner.useEngine("ES_ID_BACK"); intelligentScanner.useOcrEngine("ES_ID_BACK"); intelligentScanner.setOcrParameters(20); intelligentScanner.setFocusParameters(5, 2); intelligentScanner.setTextToScreen("Capturing the BACK of the

ID"); intelligentScanner.enableCaptureAdvice(Color.argb(255, 230,

100, 40), Color.WHITE, 10, 10, 20); intelligentScanner.setAdviceTextToScreen("Advice: Slide the

exposure bar to improve the capture."); intelligentScanner.setDocumentNameTextToScreen("ID | BACK",

Color.argb(255, 230, 100, 40)); intelligentScanner.enableBrightnessBar(Color.argb(255, 255,

255, 255),Color.argb(255, 230, 100, 40) ); intelligentScanner.enableTemplate(Color.argb(255, 230, 100,

40)); intelligentScanner.enableFeatures(Color.argb(255, 25, 155,

215)); intelligentScanner.enableFocusFilter(); intelligentScanner.setImageQuality(-1, -1, -1); intelligentScanner.aggressiveCapture(true); intelligentScanner.generatePostProcessImage(true); intelligentScanner.runScanner("ES_ID_BACK", this, 5002); }

}

65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:92:93:94:95:

Page 25: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

As saving of the image to post-process has been enabled, now we can also obtain its name as well as theOCR result:

04/04/2018 25/31

protected void onActivityResult(int requestCode, int resultCode, Intent intentData){ JSONObject data = intelligentScanner.getMrzData();

if(requestCode == 5002){

if( intelligentScanner.getBackButtonPressed() == false){

try { textView.setText( "Name: " + data.getString("name") + "\n" + "Surname: " + data.getString("surname") + "\n" + "ID: " + data.getString("optionalData") + "\n" + "Birth Date: " + data.getString("birthDate") + "\n" + "Gender: " + data.getString("gender") + "\n" + "Nationality: " + data.getString("nationality") +"\n" + "Expiry Date: " + data.getString("expiryDate") + "\n" + "Document Type: " + data.getString("documentType") +

"\n" + "Issuing State: " + data.getString("issuingState") +

"\n" + "Document Number: " +

data.getString("documentNumber"));

}catch (JSONException e) { e.printStackTrace(); }

} }}

117:118:119:120:121:122:123:124:125:126:127:128:129:130:131:132:133:134:135:136:137:138:139:140:141:142:143:144:145:146:147:118:

Page 26: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

For the barcode case, you can also enable a series of properties that will improve the capture:

• Enable the brightness bar and arrow animation

• Set the text to display on the screen while the capture is being carried out

• Set the text that will be displayed as a warning message if the capture is not carried out

• Set the text to display on the screen with the name of the document to be captured

• Enable the preview template for barcodes

• Enable shading outside the inner area of the template

• Enable animation of the preview line

• Enable the function that will display the warning message

• Enable the function that returns the barcode format

• Enable the function that will verify the capture

• Enable the function that will verify the way in which application control is returned

04/04/2018 26/31

public void onClickCB(View V){

intelligentScanner.useEngine("BARCODE");

intelligentScanner.setTextToScreen("Capturing 1D BARCODE"); intelligentScanner.setAdviceTextToScreen("Advice: Slide the exposure

bar to improve the capture."); intelligentScanner.setDocumentNameTextToScreen("Barcode",

Color.argb(255, 255, 255, 255) );intelligentScanner.enableBarcodeTemplate(

intelligentScanner.barcodeTypeClass.Unidimensional, Color.argb(255, 230, 100, 40));

intelligentScanner.enableBarcodeBackground(intelligentScanner.barcodeTypeClass.Unidimensional);

intelligentScanner.enableBarcodeAnimation(intelligentScanner.barcodeTypeClass.Unidimensional);

intelligentScanner.disableBarcodeAnimation(intelligentScanner.barcodeTypeClass.Unidimensional);

intelligentScanner.enableCaptureAdvice(Color.argb(255, 230, 100, 40), Color.WHITE, 10, 10, 20);

intelligentScanner.runScanner("BARCODE",this, 6001);

}

94:95:96:97:98:99:100:101:102:103:104:105:106:107:108:109:110:111:112:113:114:115:116:117:

Page 27: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

04/04/2018 27/31

protected void onActivityResult(int requestCode, int resultCode, Intent intentData){ if(requestCode == 6001){

if( intelligentScanner.getBackButtonPressed() == false){

textView.setText( "Result: " + intelligentScanner.getBarcodeResult() + "\n" + "Barcode format: " + intelligentScanner.getBarcodeFormat()

+ "\n" + "The document is verified: " +

intelligentScanner.getDocumentVerified() + "\n" + "The BACK button was pressed: " +

intelligentScanner.getBackButtonPressed() );

} }

}

117:118:119:120:121:122:123:124:125:126:127:128:129:130:131:132:133:134:135:136:

Page 28: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Appendices

Use of the capture screen

Documents (ID, Residence Cards, Passports, Cheques and Cards)

The automatic document capture screen is launched through the runScanner() function, the SDK takescontrol of the screen and the thread of execution. As we see in the above image, this screen has fourcharacteristics:

– In the centre, the ID is located in a template. This guides the user to make the capture in the mosteffective way. This template is enabled by means of the enableTemplate() function. You can alsosee the features that correspond to the extracted characteristics. This functionality is activatedthrough enableFeatures().

– At the top, the name of the document type for capture is indicated, in this case the front of the ID.This functionality is enabled by means of the getDocumentNameTextToScreen() function.

– At the bottom, the message previously set by the programmer with the setTextToScreen() functionis displayed.

– If the automatic brightness is not set in accordance with your needs, the sliding bar on the right ofthe screen allows the brightness of the capture to be increased and reduced. This functionality isenabled by means of the enableBrightnessBar() function. The developer can then call thegetCaptureName() function to get the capture name.

Once a document is captured, the SDK saves the processed image, returns control of the screen and thethread of execution.

Finally if you wish to return to the previous screen or cancel the capture, the back button (←) provided bythe device should be used. At this time, the SDK returns control of the screen and the thread of execution.

04/04/2018 28/31

Page 29: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

If it was not possible to carry out a capture, the text previously preset by the programmer is disabled byenableCaptureAdvice() function, in this case “Capturing the FRONT of the ID”. Another message is enabledwith an advice to facilitate the capture. The message text can be parametrised by using thesetAdviceTextToScreen() function, in this case “Advice: Slide the exposure bar to improve the capture”.With the enableCaptureAdvice() function, the two arrows that move at the side of the exposure bar arealso enabled, as well as the three timeouts. The first specifies the time that elapses from when the camerais enabled until when the warning message appears; the second specifies the time that elapses from whenthe advice is enabled until the forced capture is enabled, and the third represents the time that elapsesfrom when the forced capture is enabled until when it automatically leaves the camera as we have still beennot able to make the capture.

04/04/2018 29/31

Page 30: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Barcodes

In the case of barcodes, the runScanner() function is also used to launch the automatic capture screen andthus the SDK takes control of the screen and the thread.

As we see in the above image, this screen has six characteristics:

• In the centre, the barcode is located in a template. This guides the user to make the capture in themost effective way. This template is enabled by means of the enableBarcodeTemplate() function.

• The outer part of the screen is dark shaded, which clearly delimits the area where the barcodeshould be placed. This functionality is enabled by means of the enableBarcodeBackground()function.

• There is a red line in the middle of the rectangle that defines the barcode capture area. This canbe animated or static, a parameter that can be controlled by means of theenableBarcodeAnimation()function.

• At the top, the type of barcode for capture is indicated, in this case a one-dimensional barcode.This functionality is enabled by means of the getDocumentNameTextToScreen() function.

• At the bottom, the message previously set by the programmer with the setTextToScreen() functionis displayed.

• Finally, the developer can call the getBarcodeResult() function in order to get a string with thecaptured barcode.

• In addition, if the capture is not carried out, the enableCaptureAdvice(), setAdviceTextToScreen(),getDocumentVerified() and getButtonBackPressed functions can also be enabled, which have thesame functions as ID or cheque cases. In this case, the getDocumentVerified() function will haveno meaning, as, in the case of barcodes, there is no model and this function will as a result alwaysreturn false.

04/04/2018 30/31

Page 31: SMAATSDK - Serimag · Release v1.0 Example of folders and files necessary for document capture The IntelligentScanner folder is created in the memory card storage (SD), which contains

IntelligentScanner Module on AndroidRequirements and DocumentationRelease v1.0

Recommendations for capture• Find a background that contrasts with the document to be captured.

• Use the application with natural light preferably.

• Use the exposure control bar if you cannot achieve capture with the above requirements.

• Avoid shade and reflections.

• Enable the template function by means of the enableTemplate() function.

• Do not tilt the camera more than 30°.

• If movements are needed, these should be smooth.

• It is recommended to enable the focus filter, except when application performance is low or youhave problems in capturing a document.

04/04/2018 31/31