ActiveRecognitionSet Property

Applies to TestComplete 15.44, last modified on November 10, 2022
This property is provided by the legacy OCR plugin. In version 12.60, the plugin was replaced with the new Optical Character Recognition plugin powered by Google Cloud Vision API. To learn more, see Optical Character Recognition.
The legacy OCR plugin was removed from TestComplete in version 12.60. If you need to use objects, methods, and properties provided by the legacy plugin with this version of TestComplete, please contact our Customer Care team. The legacy OCR plugin was restored in TestComplete version 14.0. To use the objects, methods, and properties with this or later TestComplete version, you need to install and enable the plugin manually.

Description

The OCROptions.ActiveRecognitionSet property defines what subset of characters (all characters, digits, uppercase letters, lowercase letters and so on) should be used for recognition. Reducing the number of recognizable characters increases the speed and accuracy of the OCR procedure.

To learn more about character recognition, see Using Optical Character Recognition.

Declaration

OCROptionsObj.ActiveRecognitionSet

Read-Write Property Integer
OCROptionsObj An expression, variable or parameter that specifies a reference to an OCROptions object

Applies To

The property is applied to the following object:

Property Value

An integer value that denotes the subset of the currently recognized characters. It can be any of the following values or a bitwise combination of them:

Value Description
0 Recognize all supported characters: 52 lower-case and upper-case Latin letters, 10 digits and 31 special characters.
1 Recognize digits from "0" to "9".
2 Recognize upper-case letters from "A" to "Z".
4 Recognize lower-case letters from "a" to "z".
8 Recognize special characters.

Example

The following example searches for digits within the text written in Windows Notepad and posts the found digits to the test log.

JavaScript, JScript

function OCROptionsSample()
{

  // Obtains the Notepad window
  var notepad = Sys.Process("notepad");
  var Window = notepad.Window("Notepad", "*").Window("Edit");

  // Captures an image of the Notepad window
  var Rect = Window.Picture();
  Log.Picture(Rect, "Region with the text to be recognized");

  // Creates an OCR object
  var OCRObj = OCR.CreateObject(Rect);
  // Creates an OCROptions object
  var OCROptions = OCRObj.CreateOptions();

  // Modifies the OCR options:
  // Specifies that the only digit will be used for recognition
  OCROptions.ActiveRecognitionSet = 1;

  // Recognizes digits within the text
  // Posts the found digits to the test log
  Log.Message("Found characters:", OCRObj.GetText(OCROptions));

}

Python

def OCROptionsSample():
  # Obtains the Notepad window
  notepad = Sys.Process("notepad")
  Window = notepad.Window("Notepad", "*").Window("Edit")
  # Captures an image of the Notepad window
  Rect = Window.Picture()
  Log.Picture(Rect, "Region with the text to be recognized")
  # Creates an OCR object
  OCRObj = OCR.CreateObject(Rect)
  # Creates an OCROptions object
  OCROptions = OCRObj.CreateOptions()
  # Modifies the OCR options:
  # Specifies that the only digit will be used for recognition
  OCROptions.ActiveRecognitionSet = 1
  # Recognizes digits within the text
  # Posts the found digits to the test log
  Log.Message("Found characters:", OCRObj.GetText(OCROptions))

VBScript

Sub OCROptionsSample

  ' Obtains the Notepad window
  Set notepad = Sys.Process("notepad")
  Set Window = notepad.Window("Notepad", "*").Window("Edit")

  ' Captures an image of the Notepad window
  Set Rect = Window.Picture()
  Call Log.Picture(Rect, "Region with the text to be recognized")

  ' Creates an OCR object
  Set OCRObj = OCR.CreateObject(Rect)
  ' Creates an OCROptions object
  Set OCROptions = OCRObj.CreateOptions

  ' Modifies the OCR options:
  ' Specifies that the only digit will be used for recognition
  OCROptions.ActiveRecognitionSet = 1

  ' Recognizes digits within the text
  ' Posts the found digits to the test log
  Call Log.Message("Found characters:", OCRObj.GetText(OCROptions))

End Sub

DelphiScript

procedure OCROptionsSample();
var notepad, Window, Rect, OCRObj, OCROptions;
begin

  // Obtains the Notepad window
  notepad := Sys.Process('notepad');
  Window := notepad.Window('Notepad', '*').Window('Edit');

  // Captures an image of the Notepad window
  Rect := Window.Picture();
  Log.Picture(Rect, 'Region with the text to be recognized');

  // Creates an OCR object
  OCRObj := OCR.CreateObject(Rect);
  // Creates an OCROptions object
  OCROptions := OCRObj.CreateOptions;

  // Modifies the OCR options:
  // Specifies that the only digit will be used for recognition
  OCROptions.ActiveRecognitionSet := 1;

  // Recognizes digits within the text
  // Posts the found digits to the test log
  Log.Message('Found characters:', OCRObj.GetText(OCROptions));

end;

C++Script, C#Script

function OCROptionsSample()
{

  // Obtains the Notepad window
  var notepad = Sys["Process"]("notepad");
  var Window = notepad["Window"]("Notepad", "*")["Window"]("Edit");

  // Captures an image of the Notepad window
  var Rect = Window["Picture"]();
  Log["Picture"](Rect, "Region with the text to be recognized");

  // Creates an OCR object
  var OCRObj = OCR["CreateObject"](Rect);
  // Creates an OCROptions object
  var OCROptions = OCRObj["CreateOptions"]();

  // Modifies the OCR options:
  // Specifies that the only digit will be used for recognition
  OCROptions["ActiveRecognitionSet"] = 1;

  // Recognizes digits within the text
  // Posts the found digits to the test log
  Log["Message"]("Found characters:", OCRObj["GetText"](OCROptions));

}

See Also

Using Optical Character Recognition
Using Optical Character Recognition - Tips

Highlight search results