Free Form OCR in Java

Demonstrates how to use Free-Form OCR to recognize text within a captured image and extract the text in digital form with the ability to resize the frame during image capture.

Download Source

Product

DataWedge - 13.0

Devices

All supported Zebra Android 13 or higher devices

Overview

Free-Form OCR digitizes printed text by extracting text within a captured image with the use of Text Recognition from Google's ML Kit. During image capture, the frame displays the target data to capture. This sample application demonstrates the use of Free-Form OCR including configuring DataWedge, registering for scanner status notifications, and using the trigger to retrieve the output via intent.

This sample app performs the following:

  • Register a broadcast receiver to listen for DataWedge intents.
  • Create a DataWedge profile named “FreeFormScanningProfile” if it does not exist and retrieve the result from the broadcast receiver. The profile includes the following configurations:
    • Enables Free-Form OCR under Workflow Input.
    • Enables Intent Output and sets the intent action, category and delivery mechanism to broadcast.
    • Associates the sample app to the "FreeFormScanningProfile" profile.
  • When scanning OCR data from any document, the data is captured and displayed with the image and text.

This sample application is only intended for educational purposes, demonstrating the use of DataWedge intent API(s).

Requirements

APIs Used

DataWedge API App Functionality
Create Profile Create the profile with specific parameters for Free-Form OCR.
Delete Profile Delete the profile if creating the profile fails.
Get Profiles List Get the list of DataWedge profiles on the device to check if a profile exists.
Set Config Set the appropriate configurations specified.
Soft Scan Trigger Start/stop or toggle the software scan trigger.

Using This Sample

  1. Download and build the sample app.

  2. Copy and install the sample app to the device.

  3. Launch the sample app.

    • DataWedge profile “FreeFormScanningProfile” is created if it does not exist.
    • If profile creation fails, the profile is deleted. Tap Re-create profile to attempt to recreate the profile.
  4. Tap Start Scanning or press the trigger button to start the scan.

  5. Place the data to capture within the target crosshair. The extracted text is displayed at the bottom of the screen. Press the Capture button or the hardware trigger when ready to capture the text.

  6. Review the text displayed to ensure the desired data is captured. When satisfied, tap Approve.

  7. The captured text is displayed along with the corresponding screen capture.

  8. Tap Clear Scan Data to clear the data displayed.


Related guides: