Skip to main content
Version: 7.0.0

Get Started

This page will guide you through the process of adding ID Capture to your Android application. ID Capture is a mode of the Scandit Data Capture SDK that allows you to capture and extract information from personal identification documents, such as driver's licenses, passports, and ID cards.

The general steps are:

  • Create a new Data Capture Context instance
  • Access a Camera
  • Configure the Capture Settings
  • Implement a Listener to Receive Scan Results
  • Set-up the Capture View and Overlay
  • Start the Capture Process
warning

Using ID Capture at the same time as other modes (e.g. Barcode Capture) is not supported.

Prerequisites

Before starting with your integration, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. See the installation guide for details.

tip

You can retrieve your Scandit Data Capture SDK license key by signing in to your account Dashboard.

External Dependencies

The Scandit Data Capture SDK modules depend on a few standard libraries that you can find listed below. If you are including the Scandit Data Capture SDK through Gradle or Maven, all of these dependencies are automatically pulled in and there is no need for you to do anything further.

If you directly add the AAR files to the project, you need to add these dependencies yourself.

  • org.jetbrains.kotlin:kotlin-stdlib:[version]
  • androidx.annotation:annotation:[version]

Module Overview

The modules that need to be included in your project depend on the features you want to use. The following table lists what modules you need to include in your project, depending on the features you want to use.

ModuleRequired for Feature
ScanditCaptureCoreRequired for all ID Capture features
ScanditIdCaptureRequired for all ID Capture features
ScanditIdCaptureBackendExtract data from visual inspection zones (e.g. the front of IDs and driver licenses, or the human-readable data on Passport)
ScanditIdEuropeDrivingLicenseExtract vehicle category data from the back of EU Driver Licenses
ScanditIdAamvaBarcodeVerificationVerify US Driver Licenses
ScanditIdVoidedDetectionReject voided IDs
tip

Note that your license may support only a subset all ID Capture capabilities. If you need to use additional features, contact us.

Create a Data Capture Context

The first step to add capture capabilities to your application is to create a new Data Capture Context. The context expects a valid Scandit Data Capture SDK license key during construction.

DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

Access a Camera

Next, you need to create a new instance of the Camera class to indicate the camera to stream previews and to capture images.

camera = Camera.getDefaultCamera(IdCapture.createRecommendedCameraSettings());

if (camera == null) {
throw new IllegalStateException("Failed to init camera!");
}

dataCaptureContext.setFrameSource(camera);

Configure the Capture Settings

Use IdCaptureSettings to configure the scanner type to use and the documents that should be accepted and/or rejected.

Check IdCaptureDocumentType for all the available options.

List<DocumentType> acceptedDocuments = new ArrayList();
List<DocumentType> rejectedDocuments = new ArrayList();

// Documents from any region:
acceptedDocuments.add(new IdCard(Region.AnyRegion));
// Only documents issued by a specific country:
acceptedDocuments.add(new IdCard(Region.Germany));
// Regional documents:
acceptedDocuments.add(new RegionSpecific.ApecBusinessTravelCard());
// Reject passports from certain regions:
rejectedDocuments.add(new Passport(Region.Cuba));

IdCaptureSettings settings = new IdCaptureSettings();
settings.acceptedDocuments = acceptedDocuments;
settings.rejectedDocuments = rejectedDocuments;

// To scan only one-sided documents and a given zone:
settings.scannerType = new SingleSideScanner(barcode = true);
// or
settings.scannerType = new SingleSideScanner(machineReadableZone = true);
// or
settings.scannerType = new SingleSideScanner(visualInspectionZone = true);

// To scan both sides of the document:
settings.scannerType = new FullDocumentScanner();

Create a new ID Capture mode with the chosen settings:

IdCapture idCapture = IdCapture.forDataCaptureContext(context, settings);

Implement a Listener

To receive scan results, implement and IdCaptureListener. The listener provides two callbacks: onIdCaptured and onIdRejected.

IdCaptureListener listener = new IdCaptureListner() {
@Override
public void onIdCaptured(CapturedId data) {
// Success! Handle extracted data here.
}

@Override
public void onIdRejected(CapturedId data, RejectionReason reason) {
// Something went wrong. Inspect the reason to determine the follow-up action.
}
}

idCapture.setListener(listener);

Handling Success

Capture results are delivered as a CapturedId. This class contains data common for all kinds of personal identification documents.

For more specific information, use its non-null result properties (e.g. CapturedId.barcode).

On a successful scan you may read the extracted data from CapturedId:

@Override
public void onIdCaptured(CapturedId data) {
String fullName = data.getFullName();
DateResult dateOfBirth = data.getDateOfBirth();
DateResult dateOfExpiry = data.getDateOfExpiry();
String documentNumber = data.getDocumentNumber();

// Process data:
processData(fullName, dateOfBirth, dateOfExpiry, documentNumber);
}
tip

All data fields are optional, so it's important to verify whether the required information is present if some of the accepted documents may not contain certain data.

Handling Rejection

The ID scanning process may fail for various reasons. Start from inspecting RejectionReason to understand the cause.

You may wish to implement the follow-up action based on the reason of failure:

@Override
public void onIdRejected(CapturedId data, RejectionReason reason) {
if (reason == RejectionReason.Timeout) {
// Ask the user to retry, or offer alternative input method.
} else if (reason == RejectionReason.DocumentExpired) {
// Ask the user to provide alternative document.
} else if (reason == RejectionReason.HolderUnderage) {
// Reject the process.
}
}

Set up Capture View and Overlay

When using the built-in camera as frame source, you may typically want to display the camera preview on the screen together with UI elements that guide the user through the capturing process.

To do that, add a DataCaptureView to your view hierarchy:

DataCaptureView dataCaptureView = DataCaptureView.newInstance(this, dataCaptureContext);
setContentView(dataCaptureView);

Then, add an instance of IdCaptureOverlay to the view:

IdCaptureOverlay overlay = IdCaptureOverlay.newInstance(idCapture, dataCaptureView);

The overlay chooses the displayed UI automatically, based on the selected IdCaptureSettings.

If you prefer to show a different UI or to temporarily hide it, set the appropriate IdCaptureOverlay.idLayout.

Start the Capture Process

Finally, turn on the camera to start scanning:

camera.switchToDesiredState(FrameSourceState.ON);