Configure text recognition settings

Relevant for: GUI tests and components

This topic describes how to configure text recognition settings.

Prerequisites

In your application, capture an image of the text you want to detect or extract.

Back to top

Analyze the characteristics of the text

Determine whether you can capture the text using a text (or text-like) property instead of using a text recognition mechanism.

Running steps that use OCR takes longer than running steps that use property-based object recognition.

Back to top

Decide which OCR engine to use

You may need to experiment with your application to find out which OCR settings achieve the best results. After you determine which OCR engine works best with your tests, we recommend using that engine consistently. Using different engines for different runs may produce different results.

When choosing an OCR engine, consider the following:

Consideration Google and Baidu (Cloud) ABBYY and Tesseract (Non cloud)
Accuracy

Choose the OCR engine that proves most accurate for your applications.

Cloud vendors provide different customer plans providing various levels of accuracy.

Availability

Requires a cloud OCR account and an available Internet connection

No need for account or Internet connection

Language support

Google Cloud OCR detects the languages automatically and supports mixed-language text. You do not have to specify which languages to expect in the application. See also Known issues - Multilingual applications.

Baidu OCR supports fewer languages than ABBYY but provides greater accuracy and better recognition in hieroglyphic languages, such as Chinese, Japanese, or Korean.

Check the list of available languages for Baidu and ABBYY in the Text Recognition pane. Baidu supports various languages separately, or text that contains Chinese and English. See also Known issues - Multilingual applications.

ABBYY OCR supports many languages, it can be configured to support multiple languages, and can recognize mixed-language text.

When using the Tesseract OCR engine, it is possible to use only one language pack at a time. See more details on language packs in Languages, below.

Performance

Affected by the quality of the Internet connection and not the computer's configuration.

Affected by your cloud platform plan.

Requires a strong processor. On older computers, may take a long time to provide result for complicated images or multilingual text.

The Tesseract OCR engine is slower than the ABBYY OCR engine. If your test has a significant use of text recognition steps (such as GetVisibleText), note that the total time required to run these tests will increase.

Back to top

Set the text recognition options

In the Text Recognition pane of the Options dialog box (Tools > Options > GUI Testing tab > Text Recognition node, set the following options:

Text Recognition option Detailed Steps
OCR engine type

Select one of the following text recognition mechanisms:

  • The ABBYY OCR (the default option)
  • The Tesseract OCR engine
  • The Google Cloud OCR engine
  • The Baidu Cloud OCR engine

The ABBYY OCR Text Recognition engine is available only if you included it in the OpenText Functional Testing installation. If ABBYY is not installed, Tesseract is used as the default engine instead.

Configure the connection to the Cloud OCR service

Using a cloud OCR engine requires setting up an account with the relevant vendor and obtaining an access token or key used to connect to the cloud service.

  • Enter your access token or key
  • If your Internet connection requires a proxy, specify the proxy server address and authentication details.
  • Press Test Connection to test your connection details and make sure OpenText Functional Testing can connect to the cloud OCR service.
Text Recognition mode

(ABBYY and Tesseract OCR engines only)

  • Single text block mode: Focuses on the area and treat it as a single text block. This is especially useful when trying to capture text on small objects or in a small text area. Select this option if the text on the object is uniform in font, size, color, and background.

  • Multiple text block mode: Instructs the OCR mechanism to handle each text area in the object that has a different background font and size. The OCR mechanism decides where to divide the text blocks according to an internal algorithm. Select this option only if the text on the object comprises different fonts, font sizes, colors, and/or backgrounds.

Languages

Available languages and supported languages (ABBYY OCR engine only)

From the list of available languages, select one or more languages to support for text recognition.

Language type (Baidu OCR Engine only)

From the list of languages, select a single language to support for text recognition, or select Chinese and English.

Current language pack (Tesseract OCR engine only)

The current language pack to use in text recognition. When using the Tesseract engine, it is possible to use only one language pack at a time.

You can download additional language packs from the Tesseract OCR engine download site: https://github.com/tesseract-ocr/tessdoc/blob/master/Data-Files.md#data-files-for-version-400-november-29-2016. After downloading, add the files to the <Installdir>/dat/tessdata4.1 folder.

Pattern Training

(ABBYY OCR engine only)

Click Use a trained pattern to help the ABBYY OCR engine identify unusual or unclear characters in your application.

You can create a trained pattern, specify an existing pattern to use, or modify an existing pattern.

For details, see Configure text recognition settings

Preview (ABBYY, Baidu, and Google OCR engines only)

Click this button to preview the text recognition result produced based on the options set in this task.

See Verify the text recognition configuration for more details.

Symbols for text recognition (Tesseract OCR engine only) Enter the list of characters you want OCR to recognize. When the test runs, text recognition is performed only on the characters specified and all others are ignored.
Use configuration from a file

(Tesseract OCR engine only) Specifies that the text recognition configuration should be loaded from an externally created file.

For details on creating a file, see https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc.

Preprocess the image before using text recognition Specifies that the background image should be processed before performing text recognition. This way, the image elements are identified before using text recognition.

Enable fast mode (Tesseract OCR engine only)

The Tesseract engine provides a fast mode to improve OCR performance. This may reduce text recognition accuracy.

The fast mode option is no longer available in the UI. The fast mode is now controlled by the data file used for OCR.

To enable fast mode:

  1. Download the language pack for fast mode from the Tesseract OCR engine site https://github.com/tesseract-ocr/tessdata_fast.

  2. Replace the file in the <Installdir>/dat/tessdata4.1 folder with the new file for fast mode.

    Note: Make sure to maintain the original file in case you want to deactivate the fast mode later.

Back to top

Verify the text recognition configuration

You can use the Preview button to verify the text recognition options you set in Set the text recognition options and then optimize your settings.

To preview text recognition results using Google or Baidu:

  1. Click the Preview button in Tools > Options > GUI Testing tab > Text Recognition node.
  2. In the Preview dialog box, click Browse to select the image file of your application, then click Recognize.
  3. View the recognition result in the right box.
  4. Adjust the Text Recognition options if necessary.

To preview text recognition results using ABBYY:

  1. Click the Preview button in Tools > Options > GUI Testing tab > Text Recognition node.
  2. In the Preview dialog box, click Browse to select the image file of your application.
  3. Select or customize a set of OCR configurations, and then click Recognize.

    For details about the OCR configuration sets and recognition parameters, see Preview Pane (Options Dialog Box > GUI Testing Tab > Text Recognition) .

  4. In the right box, view the recognition result produced based on the configuration set you selected or customized and the OCR options you set in the Text Recognition pane.
  5. Adjust your text recognition settings if necessary.

    You can adjust the settings globally in the Options Window, or locally for a specific test run in the test itself.

    To adjust locally for a test run in the test, click Generate Script to generate the selected or customized set of ABBYY OCR parameter settings (SetABBYYParameters steps) and then click Copy Script to copy to your test.

    Tip:  

    • If you want ABBYY OCR parameter settings to affect images whose text was already retrieved in the same test run, insert a ClearOCRCache step before the SetABBYYParameters steps you added.

    • After using ABBYY OCR parameter settings for part of the test run, you can return to the global ABBYY OCR settings by using a ResetABBYYParameters step.

Back to top

ABBYY OCR Pattern Training

Train the ABBYY OCR engine to identify unusual or unclear characters in your application.

Provide images containing your characters, and specify which characters the various shapes represent. You can create a trained pattern, specify an existing pattern to use, or modify an existing pattern.

Note: Pattern training is not supported for Chinese, Japanese, or Korean languages. If you select those languages for text recognition, the Use a trained pattern option is unavailable.

To create a trained pattern:

  1. In the Tools > Options > GUI Testing tab > Text Recognition node:

    Select Abbyy OCR for the OCR Mechanism, and click Use a trained pattern to activate the pattern training options.

  2. (Optional) Enter the path to a new or existing .ptn file in which to save the trained pattern.

    Do one of the following:

    • Enter the path manually.

    • Click Open and browse to an existing pattern file.

    • Click New and browse to the folder in which you want to create the pattern file.

    If you don't enter a path, a new trained pattern file is created with an automatically generated name and location.

    If you specify an existing pattern file, patterns you train are added to this file without overwriting its current content.

  3. Click Train a user pattern.

  4. Click Browse and select an image file containing the characters for ABBYY to learn.

    The following image file types are supported: .jpg, .jpeg, .bmp, .png

  5. Click Train a user pattern. The Pattern Training dialog box opens and highlights a character.

  6. If the character is correctly identified, click Skip to move to the next character.

  7. Otherwise, follow the instructions in the dialog box to adjust the borders of the character to identify and specify which character it is.

    If necessary, you can create a compound character, by highlighting consecutive characters in the image, and specifying the string of characters they represent.

  8. Click Train. The next character in the image is displayed. Repeat the training steps until you reach the end of the file.

    Tip:  

    • Traversing all of the characters in an image may take some time. You might want to divide your application into a number of images.

    • In some cases, such as at the end of a long or interrupted training session, an unexpected error message is displayed. You can click OK or Continue to close the message and ignore it.

  9. Use the Preview option to test the text recognition. For details, see Verify the text recognition configuration.

To specify an existing pattern to use: 

  1. In the Tools > Options > GUI Testing tab > Text Recognition node:

    Select Abbyy OCR for the OCR Mechanism, and click Use a trained pattern to activate the pattern training options.

  2. Enter the path to an existing .ptn file, or click Open to browse to an existing file.

  3. Use the Preview option to test the text recognition. For details, see Verify the text recognition configuration.

If you already have a trained pattern, you can also use automation scripts to specify the trained pattern file to use for text recognition. For details, see the App.Options.PatternFileLocation property in the UFT One Automation Object Model Reference.

To edit an existing pattern: 

  1. In the Tools > Options > GUI Testing tab > Text Recognition node:

    Select Abbyy OCR for the OCR Mechanism, and click Use a trained pattern to activate the pattern training options.

  2. Enter the path to an existing .ptn file, or click Open to browse to an existing file.

  3. Click Edit. The User Pattern dialog box opens.

  4. You can see the images of the trained characters, change their properties, or remove them from the training pattern.

  5. Use the Preview option to test the text recognition. For details, see Verify the text recognition configuration.

Note: The Pattern Training and User Patter dialog boxes are part of the ABBYY OCR. Therefore, these dialog boxes are displayed in the system's language and not the language configured for OpenText Functional Testing.

For more details on pattern training, see the ABBYY documentation.

Back to top

See also: