Skip to main content
Version: 10.3

Add OCR step to Business Process

In Work.AI, the no-code OCR step lets you accomplish the following:

  • Process documents asynchronously without submitting redundant tasks to Workers and receive responses instantly in Control Tower.

  • Recognize a document and get an output compatible with a labelling Manual Task.

Create Business Process with no-code OCR step

To build a BP with a no-code OCR step, follow the steps below:

  1. Create a BP as described in the guide.

  2. Navigate to the Workflow tab of the newly created BP. In the Reusable components panel on the right, go to the Bot tab and click Models to open the list of available no-code steps.

  3. Add the OCR step to the Workflow Designer canvas in one of the following ways:

    • Copy an existing step. In the Reusable components panel, hover over the OCR step and click the displayed Copy button. As a result, you create an independent OCR step instance: the changes you make in the copy are not synchronized with the source.

    • Reuse an existing step. Drag an existing OCR step from the Reusable components panel to the canvas. In this case, any changes you make to the step are applied across all BPs where the same step is included.

  4. Double-click the step on the canvas and, if you want your BP to be schema-based, navigate to the Input / Output tab of the OCR step to set up the input and output contracts. For details, read the guide.

    You do not need to set the step contracts if you set the contracts for the entire BP.

  5. Go back to the Design tab and specify required parameters. For detailed parameter descriptions, see Input parameters.

    If you select Google Vision or Azure AI Document Intelligence as your OCR engine, check the default configuration includes the following parameters:

    • OCR Type: Enriched
    • OCR Google parameters json:
      • exportFormat: xmlForCorrectedImage,xmlWithoutRecognitionVariants
      • writeRecognitionVariants: true
      • skipPreprocessing: false
      • storePreprocessedDoc: true
      • timeout: 60
    caution

    If any of the settings are not configured as above for Google Vision or Azure, OCR throws an exception.

  6. Go back to the Design tab and click Save again. The BP is now ready for OCRing incoming documents.

tip

For an end-to-end tutorial on creating a BP with no-code OCR, Model, and Manual Task steps, see the guide.

Set up OCR REST configuration properties

warning

The Azure, Google Vision, and Paddle OCR providers are available only from the OCR step. ABBYY is available both from REST API and the OCR step.

PropertyDefault valueDescription
execution.bridge.task.queueexec.<CT_HOST>.result.ocrName of the OCR step queue
execution.bridge.prefetch.count100Prefetch count of the OCR step queue
execution.bridge.thread.count20Count of threads for consuming messages of the OCR step queue

Configure OCR step parameters

Input parameters

ParameterCodeDefault valueDescription
Document URLdocument_urloriginal_document_urlSpecify the URL of the document to be processed by OCR. Typically, the data comes from the BP input.
When the step failsgo_forward_on_failureComplete the step and move to the next one with an error (yes)Specify the action to be done if the failure result is received. If you choose Complete the step and move to the next one with an error (set the code value to yes) and the failure answer is received, the step is completed, and an error message is sent to the next step.
OCR typeocr_typeEnrichedSelect Standard or Enriched. In the latter case, you enable preparing the OCR output for a labelling Manual Task.
S3 bucket names3_bucket_namedoc-uploadSpecify the S3 bucket to store the OCR output.
S3 folder names3_folder_nameemptySpecify the S3 folder to store the OCR output.
OCR engineocr_providerABBYYSelect an OCR provider:
  • ABBYY
  • Google Vision
  • Azure AI Document Intelligence
  • Paddle OCR
OCR parametersocr_parametersSee belowSee the parameters in the table below.

OCR JSON sample

Below is a JSON sample with default values you can find in the OCR parameters field:

{
"profile": "dataExtraction",
"exportFormat": "xmlForCorrectedImage,xmlWithoutRecognitionVariants",
"language": "English",
"correctOrientation": true,
"writeRecognitionVariants": true,
"discardColorImage": false,
"skipPreprocessing": false,
"removeGarbageSize": 0,
"lowResolutionMode": false,
"enhanceLocalContrast": false,
"changeDPI": 0,
"storePreprocessedDoc": true,
"textTypes": [
"normal",
"handwritten"
],
"timeout": 240,
"detectLanguage": true,
"detectTextOnImage": true,
"detectHandwritten": true,
"detectCheckmarks": true,
"nativePdfRecognition": false
}

OCR parameters

The table below lists all available OCR parameters and their descriptions:

ParameterValuesDescription
profileA scenario for fine-tuning the OCR engine to do a specific task.
documentConversionConverts documents into editable formats.
textExtractionExtracts text from documents.
barcodeRecognitionExtracts barcodes.
dataExtractionThe dataExtraction scenario is used to extract all possible data from a document and store it in a structured way. The result represents a document structure storing all document objects: printed and handwritten text, tables, barcodes, checkmarks, and images with their location and attributes. This format is optimal for further processing, storing data in a database, or integrating with another application.
exportFormatxmlForCorrectedImageRepresents the OCR API export format. You can define multiple export formats using a comma as a separator: xml,xmlForCorrectedImage. For correct processing of a labelling MT, you cannot use more than three export formats.
txtIt is the default export format.
xmlContains characters or words along with their location in the original document (coordinates or frames).
xmlWithoutRecognitionVariantsThe same as xml but does not contain character-related data.
xmlForCorrectedImageThe same as xml, except the location is taken from a processed or adjusted document.
pdfSearchable
html
language
  • English
  • German
  • so on
Defines the default OCRed document language. You can also define multiple languages using a comma as a separator: English,German,Polish.
correctOrientationbooleanDetects the page orientation. If it differs from normal, the page is rotated automatically.
writeRecognitionVariantsbooleanFor the xml and xmlForCorrectedImage formats, provides variants of characters or words that OCR considers a possible recognition result.
discardColorImagebooleanLeaves only the black-and-white plane in a prepared image.
skipPreprocessingbooleanDisables all preprocessing steps for a document. The default value is false. If you set to true, the convertTo and changeDPI parameters are disabled.
useDefaultPatternbooleanIf true, it requires applying the default pattern from the OCR application bundle.
removeGarbageSizeintegerRemoves garbage, such as excess dots smaller than a specific size. The setting is optional, and the valid values are > 0 and -1.
lowResolutionModebooleanImproves the recognition of images with low resolution.
enhanceLocalContrastbooleanSpecifies whether the local contrast of an image should be increased.
convertTononeAutomatically detects the file type and converts it to TIFF before processing. Accepts the PDF, PNG, JPG, JPEG formats.
changeDPIinteger

valid range from 50 to 3200

null or 0 for disable

Specifies the resolution value, for example, changeDPI=300. The recommended resolution for a source image is 300 DPI for typical texts (10 pt or larger) and 400-600 DPI for texts in smaller fonts (9 pt or smaller).
storePreprocessedDocbooleanSpecifies whether preprocessed documents should be saved in the data storage.
textTypes
  • normal
  • handwritten
  • typewriter
  • matrix
  • ocrA
  • ocrB
  • e13b
Specifies the type of the text in the document. You can define several text types using a comma as a separator: normal,matrix.
timeoutintegerSets the maximum allowed timeout in seconds for a single task execution by an OCR Worker. The timeout countdown starts when an OCR Worker begins executing a task. When the task execution exceeds the given timeout, the task is forcibly killed. If you do not set the value, the default value (0) is used, and your BP does not have time to process a task.
detectLanguagebooleanSpecifies whether the OCR engine should automatically detect the recognition language of a text. Auto detection is intended to be used during the recognition of documents the language of which is not known to you.
detectTextOnImagebooleanSpecifies whether the OCR engine should automatically detect text in images.
detectHandwrittenbooleanSpecifies whether the OCR engine should automatically detect handwritten text.
detectCheckmarksbooleanSpecifies whether the OCR engine should automatically detect checkmarks.
nativePdfRecognitionbooleanIf set to true, all native PDFs are processed without OCR, which allows to save OCR license usage.

If native_pdf_processing is set to true, the skipPreprocessing and convertTo parameters are disabled. Such parameters as changeDPI and storePreprocessedDoc take effect only after you save pages of an input PDF.

troubleshooting

In case of issues with input data, see Issues related to input data.

Output parameters

  • OCR result: document processing results in the JSON format

    • Code: ocr_result

    • Example:

      {
      "originalDocument": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/1.pdf",
      "documents": {
      "xmlForCorrectedImage": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/1- xmlForCorrectedImage.xml",
      "xmlWithoutRecognitionVariants": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/1-xmlWithoutRecognitionVariants.xml"
      },
      "pageDetails": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/preprocessed/links.json"
      }
  • Task ID: the ID of an OCR task

    • Code: task_id
    • Example: 066416ed-20e8-4e96-9df1-7f7e133f1211
  • Meta info JSON: extended info for the labelling Manual Task

    • Code: meta_info_json

    • Example:

      {
      "pages": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/preprocessed/links.json",
      "ocrXmlUrl": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/1-xmlWithoutRecognitionVariants.xml",
      "imageUrl": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/1.pdf"
      }
  • Process time: record process time in milliseconds

    • Code: _sys_ocr_process_time
    • Example: 24053

See an output JSON sample for https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/preprocessed/links.json below:

[
{
"imgUrl": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/preprocessed/1.png",
"charsUrl": "https://HOSTNAME-s3-ui.cloud.workfusion.com/buckets/doc-upload/browse/bp-id/task-id/preprocessed/1.json",
"height": 3300,
"width": 2550,
"charsCount": 2216
}
]

To set your Java Native Worker to work with the OCR step data, use the respective dependency from the WorkFusion's repository:

<groupId>com.workfusion.spa</groupId>
<artifactId>bridge-step-contracts</artifactId>

Using the library facilitates the implementation and reduces the time to production for such solutions.