DataWedge OCR Image

By @darryncampbell

DataWedge 11.2 introduces new, powerful options to capture data with advanced "Workflows" including the ability to highlight specific barcodes in the field of view, capture images with the scanner and OCR (optical character recognition) for real world objects such as ID cards or vehicle license plates.

This is the fourth and final part of a series of posts that looked into the new Workflows feature. Previous posts can be found here:

  1. barcode highlighting
  2. free-form image capture
  3. DataWedge OCR | What it is and how to control it
  4. DataWedge OCR | Identity Documents

I have developed a sample application to demonstrate many of these features but please be aware that it is unsupported.

Official documentation for OCR is spread over multiple sections on the techdocs portal:

DataWedge OCR for Identity Documents

DataWedge 11.2 introduces the first "Early Access" version of OCR for real world objects:

My previous post looked at OCR for the following objects: License Plates, Vehicle Identification Numbers (VIN), Tyre Identification Numbers (TIN), Meters (digital or analog dials e.g. gas or electric meters).

This post will concentrate on Identification documents. There are many similarities between OCR for identity documents and other types of DataWedge Workflow OCR, so this post will concentrate on where ID cards differ from processing license plates, VIN, TIN and meters.

Licensing OCR

You can experiment with all OCR features using DWDemo without obtaining any kind of license

Licensing is on a per-feature basis and is time-based. For more information on licensing, please see my previous OCR post

OCR: Identity Documents

DataWedge 11.2 introduces OCR for identity documents which at launch are:

  • National ID cards
  • Driving licenses

This list will grow in the coming months, so please see the Techdocs help page for the most up to date list.

Possible uses for OCR (Identity Documents)

Quickly scan and recognize the text in a large number of supported ID cards.

At launch this will cover a selection of drivers licenses & identification cards across the following:

  • United States
  • Canada
  • LATAM (Mexico)
  • EMEA and EU (selected countries)
  • Africa (selected countries)
  • Australia (selected territories)

Again, this list will expand after this post is published, please refer to the supported list on TechDocs for up to date information.

How to configure OCR (Identity Documents)

You configure DataWedge OCR for identity documents in the same way that any other type of DataWedge workflow OCR is configured. Please refer to the "How to configure OCR (License Plates, VIN, TIN, Meters)" section of the previous post

Special considerations for ID cards

At the time of writing there are no special configuration options for recognizing ID cards. Any supported ID card placed in the field of view will be recognized.

How to use OCR (Identity Documents)

  • The hardware or software trigger will initiate the data acquisition session
  • As the system performs OCR, it will highlight the area it is recognizing
  • Once recognized, the data will be returned to the calling app. Do NOT press the trigger to capture data.
  • If nothing was recognized before the timeout, no data is sent to the calling app.

Video Demos of OCR (Identity Documents)

Please see the following short demo for ID card recognition, developed by our technical and marketing teams. You can try this yourself with DWDemo and the sample ID card:

OCR: Identity documents

Recognizing an ID card with DWDemo

Coding and OCR (Identity Documents): Receiving Data

The primary difference between OCR for identity documents and OCR for other objects is how DataWedge will parse the data for you. Whereas other objects return a single, recognized string_data result, identity cards will return upwards of 55 different attributes related to the card.

Obviously no single card will contain all of these attributes since the possible fields are designed to cover every card type. The full list of fields is given in the workflow programming guide.

To detect that an ID card has been scanned, use a label known to exist in that identity card , for example 'lastName'. :

String data = intent.getStringExtra("com.symbol.datawedge.decode_data");
Log.d(LOG_TAG, "Decode Data: " + data);
if (data != null)
  JSONArray dataArray = new JSONArray(data);
  for (int i = 0; i < dataArray.length(); i++)
    JSONObject workflowObject = dataArray.getJSONObject(i);
    if (workflowObject.has("string_data"))
      String label = workflowObject.getString("label");
      if (label.equalsIgnoreCase("lastName"))
      //  else if other type of OCR

Then parse the entire returned JSON object:

private void parseIdentityDocument(JSONArray dataArray) throws JSONException {
  String lastName = "?";
  String firstName = "?";
  for (int i = 0; i < dataArray.length(); i++)
    JSONObject workflowObject = dataArray.getJSONObject(i);
    if (workflowObject.has("string_data")) 
      String label = workflowObject.getString("label");
        if (label.equalsIgnoreCase("lastName"))
          lastName = workflowObject.getString("string_data");
        else if (label.equalsIgnoreCase("firstName"))
          firstName = workflowObject.getString("string_data");
        //  else if / case ... for each of the other possible parameters
  Log.d(TAG, "First Name: " + firstName + ", Last Name: " + lastName);

Coding and OCR (Identity Documents): Configuring DataWedge

1. At Runtime:

As discussed in my previous post, a new API has been introduced in DataWedge 11.2, Switch Data Capture, to allow you to switch from 'regular' scanning to any of the workflow input options.

The full code example in the help docs for Switch Data Capture, summarized below, shows how to switch to OCR (ID cards) and should be treated as the authoritative source:

Intent i = new Intent();
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "WORKFLOW");

Bundle paramList = new Bundle();
Bundle paramSet1 = new Bundle();
Bundle moduleAParams = new Bundle();
  moduleAParams.putString("session_timeout", "25000");
ArrayList<Bundle> paramSetList = new ArrayList<>();
paramList.putParcelableArrayList("workflow_params", paramSetList);
i.putExtra("PARAM_LIST", paramList);


2. Persistently:

A new section has been added to the existing SetConfig API for Workflow Input. There are no special considerations for Identity cards when calling SetConfig, and an example is available on TechDocs which can be used as a template.

Coding and OCR (Identity Documents): Registering for Change

Registering for changes in the workflow plugin status was covered in the previous post and will behave the same for all DataWedge OCR configurations. Please see the section "Coding and OCR (License Plates, VIN, TIN, Meters): Registering for Change"

Some additional notes for OCR (Identity Documents)

  • Passports and Visas are not supported through DataWedge OCR through the Workflow input plugin but you can still use the barcode input plugin OCR capabilities which recognizes the OCR_A and OCR_B typefaces.
  • Performance may be impacted by reflections, lighting conditions, dirt, abrasion, poor background contrast
  • Some accented characters are not yet supported, e.g. ñ or á but support is coming in the future.

Not to be confused with...

Even users familiar with DataWedge may confuse some of these new features with existing ones. Below is a list of similar, though unrelated capabilities

  • The Intent Output plugin setting for 'Use Content providers' is not used for Workflow or barcode highlighting.
  • Similarly, although the principle is similar, do not use the content provider programming guide to extract images from the workflow data. Instead use the workflow programmer's guide
  • The "OCR params" under "Scanner Configuration" is something separate and is designed to only handle the typeface used on documents such as passports and visas. This is not related to the OCR feature of workflow.