Get Started With Scandit ID Capture#

Quick overview#

ID Capture provides the capability to scan personal identification documents, such as identity cards, passports or visas. In this guide you will learn step by step how to add ID Capture to your application. Roughly, the steps are:

Note

Using ID Capture with other modes (e.g. Barcode Capture or Text Capture) is not supported.

Prerequisites#

Before starting with adding a capture mode, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. If you have not done that yet, check out this guide.

Note

You can retrieve your Scandit Data Capture SDK license key, by signing in to your account at ssl.scandit.com.

Please note that your license may support only a subset of ID Capture features. If you would like to use additional features please contact us at support@scandit.com.

Create the Data Capture Context#

The first step to add barcode 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.

const context = Scandit.DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

Adding the Camera#

You need to also create Camera:

const camera = Scandit.Camera.default;
context.setFrameSource(camera);

const cameraSettings = Scandit.IdCapture.recommendedCameraSettings;

// Depending on the use case further camera settings adjustments can be made here.

if (camera != null) {
  camera.applySettings(cameraSettings);
}

Adding the Data Capture View#

Next, in order to actually see the camera feed on the screen, create an instance of DataCaptureView and add it to your view hierarchy. For example:

const view = Scandit.DataCaptureView.forContext(context);
view.connectToElement(htmlElement);

Create ID Capture Settings#

Use IdCaptureSettings to configure the types of documents that you’d like to scan. Check IdDocumentType for all the available options.

const settings = new Scandit.IdCaptureSettings();
settings.supportedDocuments = [
  Scandit.IdDocumentType.IdCardVIZ,
  Scandit.IdDocumentType.AAMVABarcode,
  Scandit.IdDocumentType.DLVIZ,
]

Implementing the Listener#

To receive scan results, implement IdCaptureListener. A result is delivered as CapturedId. This class contains data common for all kinds of personal identification documents. For more specific information use its non-null result properties (for example CapturedId.aamvaBarcodeResult).

const listener = {
  didCaptureId: (idCapture, session) => {
    if (session.newlyCapturedId.aamvaBarcode != null) {
        // Handle the information extracted.
    }
  },
  didFailWithError: (idCapture, error, session) => {
    // Handle the error.
  }
};

Create a new ID Capture mode with the chosen settings. Then register the listener:

idCapture = Scandit.IdCapture.forContext(context, settings);
idCapture.addListener(listener);

The last thing that needs to be done is enabling the mode and turning on the camera:

camera.switchToDesiredState(Scandit.FrameSourceState.On);

And this is it. You can now scan documents.

Supported documents#

You can find the list of supported documents here.

What’s next?

To dive further into the Scandit Data Capture SDK we recommend the following articles: