Skip to main content
Version: 10.2.8

Configure OCR Bridge step and OCR providers

The OCR Bridge step lets you process documents in a Business Process (BP) and pass optical character recognition (OCR) results to the next step, such as a Model or labelling Manual Task step.

Add no-code OCR Bridge step to Business Process​

To add a no-code OCR Bridge step to a BP, follow the steps below:

  1. In an existing BP, navigate to the Workflow tab.

  2. In the step panel on the right, select Bot and click No-Code Bridge to open the list of available no-code steps.

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

    • Reuse an existing step. Drag an existing No-Code OCR Bridge step from the panel on the right to the canvas. In this case, any changes you make to the step are applied across all BPs where the same step is included.

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

  4. Double-click the step on the canvas and set a name for the step in the Name field.

  5. Navigate to the Input / Output tab of the OCR step to set up the input and output contracts.

    Note that if you set up the inputs and outputs, the whole BP becomes a schema-based one, and you will have to configure inputs and outputs for the rest of the steps in the same BP (if those are not configured yet). For details, see the guide.

  6. Go back to the Design tab and configure the OCR step parameters.

  7. Click Save to save the created OCR configuration.

Alternatively, you can use a regular OCR Bridge step to set up the OCR processing in a BP. The setup sequence is similar to the one described above.

Configure OCR step​

To configure an OCR step, double-click the step in the canvas to open the configuration window (if it is not open yet) and perform the following actions on the Design tab:

  1. Set the OCR step input parameters.

  2. Choose an OCR engine.

  3. Set the OCR parameters corresponding to the chosen OCR engine.

Set step input parameters​

ParameterCodeDefault valueDescription
Document URLdocument_urloriginal_document_urlURL of the document to be processed by OCR
OCR Typeocr_typeEnrichedOCR type values: Standard and Enriched (prepare output for a labelling Manual Task)
S3 bucket names3_bucket_namedoc-uploadS3 bucket to store results
S3 folder names3_folder_nameemptyS3 folder to store results
OCR Providerocr_providerABBYYOCR provider:
  • ABBYY
  • Google Vision
  • Azure Form Recognition
OCR parametersocr_parametersSee OCR JSON sampleSee the OCR parameters.

Choose OCR provider​

To configure an OCR provider, choose one from the OCR Provider drop-down list and set the required paratemers. For details, read Set OCR parameters.

Work.AI supports the following OCR providers:

  • ABBYY
  • Azure AI Document Intelligence
  • Google Vision

For providers other than ABBYY, mind the following considerations:

  • If you select Google Vision or Azure AI Document Intelligence, check that the default configuration includes the following parameters:

    • In the OCR Type field, choose Enriched.

    • In the OCR parameters json box, update the settings as follows:

      • exportFormat: xmlForCorrectedImage,xmlWithoutRecognitionVariants
      • writeRecognitionVariants: true
      • skipPreprocessing: false
      • storePreprocessedDoc: true
      • timeout: 60

      Note: if any of these settings are not configured as listed, OCR throws an exception.

  • To use Google Vision or Azure AI Document Intelligence, set up additional Secrets Vault credentials.

Set Secrets Vault credentials​

The Work.AI platform does not manage Google secret keys and Azure credentials, so you must add them using one of the methods described below.

Method 1. New installation

As you install Work.AI, set the following properties in config.yml:

  • ocr_google_key
  • ocr_azure_password
  • ocr_azure_endpoint
note

ocr_google_key must contain a Base64-encoded JSON Google key. Otherwise, escaping issues can occur in Ansible. If you pass the key as JSON or as separate properties, the private key can cause issues because it contains \n new lines and vault values with new lines.

Method 2. Existing installation

Set or create the same properties in config_overrides.yml in /opt/workfusion/wf_installer.

To override the parameters in the backup, run:

./install.sh install installer-backup -e @config_overrides.yml

To restart the OCR service with the parameters from config_overrides.yml, run:

./install.sh configure ocr -e @config_overrides.yml

If the steps above cause errors, make sure that the Ansible vault pass and key properties are set:

cd /opt/workfusion/wf_installer

export ANSIBLE_VAULT_PASS=$(cat config_overrides.yml | grep ansible_vault_password | cut -c 25- | tail -1)

export ANSIBLE_PRIVATE_KEY_FILE="id_rsa"

Set OCR parameters​

ParameterValuesDescription
exportFormatOCR API export format. You can define multiple export formats using a comma as a separator: xml,xmlForCorrectedImage. Mind that, for correct processing of a labelling Manual Tasks, you cannot use more than three export formats.
txtDefault 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
Predefined language. You can also define multiple languages using a comma as a separator: English,German,Polish.
correctSkewbooleanThe page skew is detected and automatically corrected.
correctOrientationbooleanThe page orientation is detected. If it differs from normal, it is rotated automatically.
writeRecognitionVariantsbooleanCauses the xml and xmlForCorrectedImage formats to contain all variants of characters or words that OCR considers a possible recognition result.
invertImagebooleanInverts images.
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.
useOnlyCustomRegionsbooleanSkips the original analyzing stage and extracts information from custom regions only.
useDefaultPatternbooleanIf true, it requires applying the default pattern from the OCR application bundle.
profiledocumentConversionConverts documents into editable formats.
textExtractionExtracts text from documents.
barcodeRecognitionExtracts barcodes.
removeGarbageSizeintegerRemoves garbage from images: excess dots smaller than a specific size. Optional; valid value > 0 and -1 for the automatically detected garbage size.
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 conversion to TIFF before processing (only conversion to TIFF is supported). Accepts images: PDF, PNG, JPG, JPEG.
changeDPIinteger

[50 : 3200] valid range

null or 0 for disable

Specifies a new value for the resolution, 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).
versionV_2 ABBYY FRE 12
V_1ABBYY FRE 11
storePreprocessedDocbooleanSpecifies whether preprocessed documents should be saved in the data storage.
textTypes
  • normal
  • 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 starts 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 Business Process (BP) does not have time to process a task.

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

troubleshooting

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

OCR JSON sample​

{
"exportFormat":"xmlForCorrectedImage,xmlWithoutRecognitionVariants",
"language": "English",
"correctSkew": true,
"correctOrientation": true,
"writeRecognitionVariants": true,
"invertImage": false,
"discardColorImage": false,
"skipPreprocessing": false,
"useOnlyCustomRegions": false,
"useDefaultPattern": false,
"profile": "documentConversion",
"removeGarbageSize": 0,
"lowResolutionMode": false,
"enhanceLocalContrast": false,
"allowedRegionTypes": null,
"changeDPI": 0,
"version": "V_2",
"storePreprocessedDoc": true,
"textTypes": ["normal"],
"timeout": 60
}

Review output​

  • OCR Result: document processing results in the JSON format

    • Code: ocr_result

    • Example:

    {
    "originalDocument": "https://minio-host/doc-upload/1.pdf",
    "documents": {
    "xmlForCorrectedImage": "https://minio-host/doc-upload/bp-id/task-id/1- xmlForCorrectedImage.xml",
    "xmlWithoutRecognitionVariants": "https://minio-host/doc-upload/bp-id/task-id/1-xmlWithoutRecognitionVariants.xml"
    },
    "pageDetails": "https://minio-host/doc-upload/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 ToD Manual Task

    • Code: meta_info_json
    • Example:
    {
    "pages": "https://minio-host/doc-upload/bp-id/task-id/preprocessed/links.json",
    "ocrXmlUrl": "https://minio-host/doc-upload/bp-id/task-id/1-xmlWithoutRecognitionVariants.xml",
    "imageUrl": "https://minio-host/doc-upload/1.pdf"
    }
  • Process time: record process time in milliseconds

    • Code: _sys_ocr_process_time
    • Example: 24053

See a JSON example for https://minio-host/doc-upload/bp-id/task-id/preprocessed/links.json below:

[
{
"imgUrl": "https://minio-host/doc-upload/bp-id/task-id/preprocessed/1.png",
"charsUrl": "https://minio-host/doc-upload/bp-id/task-id/preprocessed/1.json",
"height": 3300,
"width": 2550,
"charsCount": 2216
}
]
tip

To set your Java Native Worker to work with OCR Bridge step data, it is recommended to 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.

Set up OCR REST configuration properties​

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