Skip to main content

Check Scanner UI Components | Android Document Scanner

Introduction

The Scanbot SDK provides the ability to scan and extract content from Checks.

The following Check standards are supported:

  • USACheck - a check compatible with the ASC X9 standard used in the USA
  • FRACheck - a check format commonly used in France
  • KWTCheck - a check format commonly used in Kuwait
  • AUSCheck - a check compatible with the Australian Paper Clearing System check standard
  • INDCheck - a check compatible with the CTS-2010 standard issued by the Reserve Bank of India in 2012
  • ISRCheck - a check format commonly used in Israel

The following fields are supported:

  • Routing Number
  • Account Number
  • Check Number
  • Sort Code
  • Aux Domestic
  • BSB
  • Extra Aux Domestic
  • Transaction Code
  • Serial Number
  • Sort Number
  • Auxiliary On Us

The Check Scanner is available as an RTU UI and as a classic component (types of components are explained here).

Integration

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

Add Feature as a Dependency

CheckRecognizer is available with SDK Package 4. You have to add the following dependency for it:

implementation("io.scanbot:sdk-package-4:$latestVersion")
implementation("io.scanbot:sdk-check-assets:$latestSdkVersion")
caution

Please do not use multiple scanners at the same time. For example, do not combine generic document scanner, health insurance scanner, text data scanner, etc. at the same time! Each scanner instance requires a lot of memory, GPU, and processor resources. Using multiple scanners will lead to performance issues for the entire application.

Initialize the SDK

In order to use the Check Scanner you need to initialize the Scanbot SDK.

import io.scanbot.sdk.ScanbotSDKInitializer

...

ScanbotSDKInitializer()
...
.initialize(applicationContext)
caution

Unfortunately, we have noticed that all devices using a Cortex A53 processor DO NOT SUPPORT GPU acceleration. If you encounter any problems, please disable GPU acceleration for these devices.

ScanbotSDKInitializer()
.allowGpuAcceleration(false)

Ready-To-Use UI Component

Ready-To-Use UI Component (activity) that is responsible for recognizing Checks is CheckRecognizerActivity.

Have a look at our end-to-end working example of the RTU components usage here.

Starting and configuring RTU Check Scanner

First of all, you have to add the SDK package and feature dependencies as described here.

Initialize the SDK as described here. More information about the SDK license initialization can be found here.

To use any of the RTU UI components you need to include the corresponding dependency in your build.gradle file:

implementation("io.scanbot:sdk-package-ui:$scanbotSdkVersion")

Get the latest $scanbotSdkVersion from the Changelog.

To start the RTU UI Check Scanner you only have to start a new activity and be ready to process its result later.

val resultLauncher: ActivityResultLauncher<CheckRecognizerConfiguration>

...

resultLauncher = registerForActivityResult(CheckRecognizerActivity.ResultContract()) { resultEntity: CheckRecognizerActivity.Result ->
if (resultEntity.resultOk) {
// `resultEntity` contains `ResultWrapper<CheckRecognizerResult>` which wraps the result and points to the specific result in one of the `ResultRepository`s (which contains cached recognition results)
val resultWrapper = resultEntity.result!!
val checkDocument = resultWrapper.resultId?.let { it ->
// here we are extracting the `CheckRecognizerResult` by `resultId` from the repository
ScanbotSDK(this).resultRepositoryForClass(CheckRecognizerResult::class.java).getResult(it)
?.let {
// here you can extract the check image and set it to the ImageView
val resultImageView = findViewById<ImageView>(R.id.check_result_image)
resultImageView.setImageBitmap(it.croppedImage)

// and return recognized Check data
it.check
}
}
// Here you can handle `checkDocument` and present recognized Check information (routing number, account number, etc.)
}
}

...

myButton.setOnClickListener {
val configuration = CheckRecognizerConfiguration()
resultLauncher.launch(configuration)
}
info

We offer some syntactic sugar for handling the result from RTU components via AndroidX Result API:

  • every RTU component's activity contains a Result class which, in turn, along with the resultCode value exposes a Boolean resultOk property. This will be true if resultCode equals Activity.RESULT_OK;

  • when you only expect Activity.RESULT_OK result code - you can use the AppCompatActivity.registerForActivityResultOk extension method instead of registerForActivityResult - it will be triggered only when there is a non-nullable result entity present.

caution

Always use the corresponding activity's static newIntent method to create intent when starting the RTU UI activity using deprecated startActivityForResult approach. Creating android.content.Intent object using its constructor (passing the activity's class as a parameter) will lead to the RTU UI component malfunctioning.

An instance of CheckRecognizerConfiguration is required for starting the RTU UI activity. It allows configuration changes through methods it exposes:

val configuration = CheckRecognizerConfiguration()
configuration.setCaptureHighResolutionImage(false)
configuration.setAcceptedCheckStandards(arrayListOf(RootDocumentType.USACheck, RootDocumentType.KWTCheck, RootDocumentType.AUSCheck, RootDocumentType.FRACheck, RootDocumentType.INDCheck, RootDocumentType.ISRCheck))

info

All parameters in CheckRecognizerConfiguration are optional.

API references for all of these methods can be found on this page.

Handling the result

Below is a simple example of presenting the result: CheckRecognizerResult fields, shown in a Toast notification.

val result: CheckRecognizerResult

Toast.makeText(this@MainActivity, result.check?.fields?.map { "${it.type.name} = ${it.value?.text}" }.toString(), Toast.LENGTH_LONG).show()

It is also possible to use the GenericDocumentWrapper successors to use strongly typed objects and conveniently get access to the fields of the corresponding check.

To receive an instance of the scanned check wrapper, use io.scanbot.check.entity.GenericDocumentLibrary or wrap() extension function as follows:

// Alternatively, use GenericDocumentLibrary.wrapperFromGenericDocument(checkDocument)
when (val wrapper = result.check.wrap()) {
is USACheck -> {
val accountNumber = wrapper.accountNumber
val transitNumber = wrapper.transitNumber
val auxiliaryOnUs = wrapper.auxiliaryOnUs
}
is AUSCheck -> {
val accountNumber = wrapper.accountNumber
val auxDomestic = wrapper.auxDomestic
val bsb = wrapper.bsb
val extraAuxDomestic = wrapper.extraAuxDomestic
val transactionCode = wrapper.transactionCode
}
...
}

Full API references for the result class are available here.

Classic component

To integrate the classic component of the Check Scanner you can take a look at our Check Scanner Example App or check the following step-by-step integration instructions.

CheckRecognizer can be used in conjunction with ScanbotCameraXView or separately. Let's have a look at an example with ScanbotCameraXView.

Add feature depedencies and initialize the SDK

First of all, you have to add the SDK package and feature dependencies as described here.

Initialize the SDK as described here. More information about the SDK license initialization can be found here.

Get CheckRecognizer instance from ScanbotSDK and attach it to ScanbotCameraXView

val scanbotSDK = ScanbotSDK(applicationContext)
val checkRecognizer: CheckRecognizer = scanbotSDK.createCheckRecognizer()
val checkRecognizerFrameHandler: CheckRecognizerFrameHandler = CheckRecognizerFrameHandler.attach(cameraView, checkRecognizer)

Add a result handler for CheckRecognizerFrameHandler

checkRecognizerFrameHandler.addResultHandler(object : CheckRecognizerFrameHandler.ResultHandler {
override fun handle(result: FrameHandlerResult<CheckRecognizerResult?, SdkLicenseError>): Boolean {
when (result) {
is FrameHandlerResult.Success -> {
val recognizerResult: CheckRecognizerResult? = (result as FrameHandlerResult.Success<CheckRecognizerResult?>).value
if (recognitionResult?.check != null) {
// do something with result here
}
}
is FrameHandlerResult.Failure -> {
} // handle license error here
}

return false
}
}

handle will be triggered every time CheckRecognizer detects a check in the camera preview frame or if a license error has occurred.

After a successful check detection you will receive the result in CheckRecognizerFrameHandler.ResultHandler callback - you will get CheckRecognizerResult object that contains all recognized data:

  • status: CheckRecognizerStatus - represents the status of the scanning process
  • check: GenericDocument? - represents all recognized check fields (accountNumber, routingNumber, checkNumber, etc.)

Full API references for the result class are available here.

You can now run your app and should see a simple camera preview that can scan check data from your document.

Add a Finder Overlay

In addition, it is recommended to add a "Finder Overlay". This feature allows you to predefine a Check area over the ScanbotCameraXView screen. By using this overlay the Check Scanner can skip the time-consuming step "Search for Check area" and perform the recognition directly in the specified "Finder Overlay" area. By using this approach the Check Scanner recognizes and extracts the Check content much faster.

Details about applying finder view logic in the layout and in the code can be found here.

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?