Skip to content

Capture OCR Data from your web app using Zebra Devices

Notifications You must be signed in to change notification settings

spoZebra/zebra-eb-ocr-wedge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zebra Enterprise Browser - OCR Wedge

Sample project that demonstrates how a web app can leverage Zebra Devices' OCR features offered by DataWedge. This integration is made possible by Zebra Enterprise Browser, an industrial browser that can interact with device OS and HW as a native app.

OCR Wedge uses machine learning to enable fine-tuned, use-case-specific models to extract data in real-time via the Zebra Android device camera and completely offline. Supported configurations:

  • License Plates
  • Identification Documents
  • Vehicle Identification Number (VIN)
  • Tire Identification Number (TIN)
  • Shipping Container ID
  • Meter Reading

Full documentation: https://techdocs.zebra.com/datawedge/latest/guide/input/workflow/#ocrwedge

Demo

zebra-eb-ocr-wedge-demo.mp4

Requirements

  • Zebra Device with camera (running A13 or later)
  • Enterprise Browser - You can download it from Google PlayStore or here
  • Mobility DNA OCR Evaluation License (or purchased one) - Please contact your Zebra Sales Rep to get it.

Setup

  • Launch Enterprise Browser
  • Copy all the files in this project inside one of these folders:
    • /sdcard/android/data/com.zebra.mdna.enterprisebrowser/
    • /enterprise/device/enterprisebrowser/
  • Close and launch again the Enterprise Browser
  • Enjoy 🦓

Background

OCR functionalities rely on DataWedge which can be controlled programmatically via Intents. Leveraging on Enterprise Browser you can send and receive intents from a web app.

Enterprise Browser integration w/ DataWedge

This project includes a pre-configured DataWedge config file that has one profile per each OCR feature. The web app switches profiles when needed by triggering an intent and get captured data through a broadcast receiver. Each profile sends acquired data to the web app using intents with different action names in order to identify the data types. You can find Enterprise Browser basic setup info here.

If you wanna know more...

  • Register DataWedge Intents in Enterprise Browser (one intent per each profile so that we can distinguish this):
    <IntentReceiver>
    <EnableReceiver value="1"/>
    <IntentAction value="com.symbol.dw.action"/>
    <IntentAction value="com.symbol.dwid.action"/>
    <IntentAction value="com.symbol.dwlp.action"/>
    <IntentAction value="com.symbol.dwvin.action"/>
    <IntentAction value="com.symbol.dwtin.action"/>
    <IntentAction value="com.symbol.datawedge.api.NOTIFICATION"/>
    <IntentAction value="com.symbol.datawedge.api.RESULT_ACTION"/>
    <IntentCategory value="android.intent.category.DEFAULT"/>
    </IntentReceiver>
  • Download DataWedge profile:
    function downloadDatawedgeFile() {
    // Copy Datawedge config to download folder
    var destination = "/sdcard/Download/datawedge.db";
    EB.RhoFile.copy("/sdcard/android/data/com.zebra.mdna.enterprisebrowser/datawedge.db", destination)
    // Send to datawedge import command from download folder
    var extras = {
    "FOLDER_PATH": "/sdcard/Download/",
    "FILE_LIST": [
    "datawedge.db"
    ]
    };
    var params = {
    intentType: EB.Intent.BROADCAST,
    action: 'com.symbol.datawedge.api.ACTION',
    appName: 'com.symbol.datawedge',
    data: {
    "com.symbol.datawedge.api.IMPORT_CONFIG": extras,
    "SEND_RESULT": "true",
    "COMMAND_IDENTIFIER": "123456789"
    }
    };
    EB.Intent.send(params);
    // hide spinner
    var divSpinner = document.getElementById("custom-overlay");
    divSpinner.hidden = true;
  • Register broadcast receiver:
    function startIntentListener(){
    EB.Intent.startListening(dwBroadcastReceiver);
    console.log("startListening");
    }
  • Switch between profiles:
    function switchToProfile(profileName, sendTrigger = true){
    var extras = {
    "com.symbol.datawedge.api.SWITCH_TO_PROFILE":profileName,
    };
    sendIntentData(extras);
    // Trigger
    if(sendTrigger){
    // Show trigger toast
    const toastLive = document.getElementById('liveToast')
    const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLive)
    toastBootstrap.show()
    setTimeout(function(){
    startCapture()
    },1000);
    }
    }
  • Parse captured data:
    function dwBroadcastReceiver(myIntentData)
    {
    console.log(myIntentData)
    if (myIntentData != null && myIntentData.action.startsWith("com.symbol.dw"))
    {
    // Get value data
    let data = myIntentData.data["com.symbol.datawedge.data_string"];
    var ouptutDiv;
    switch (myIntentData.action) {
    case "com.symbol.dwid.action":
    ouptutDiv = document.getElementById("id_output");
    console.log("Identification Document: " + data);
    break;
    case "com.symbol.dwlp.action":
    ouptutDiv = document.getElementById("lp_output");
    console.log("License Plate: " + data);
    break;
    case "com.symbol.dwvin.action":
    ouptutDiv = document.getElementById("vin_output");
    console.log("VIN (Vehicle Identification Number): " + data);
    break;
    case "com.symbol.dwtin.action":
    ouptutDiv = document.getElementById("tin_output");
    console.log("TIN (Tyre Identification Number): " + data);
    break;
    default:
    console.log("AN ERROR OCCURED - WRONG PROFILE");
    break;
    }
    // Display data
    ouptutDiv.innerHTML = data;
    }
    else {
    console.log("Intent action is not registered...");
    }
    }