RecognitionRejectionAuto Property

Applies to TestComplete 12.60, last modified on September 17, 2018
The Optical Character Recognition feature provided by the OCR plugin is deprecated. It was removed from TestComplete in version 12.60 and is no longer available for later versions.
Instead, TestComplete version 12.60 introduces the new Optical Character Recognition engine featuring Google Cloud Vision API. To learn more, see Optical Character Recognition.
If you need to use the legacy feature, please contact our Customer Care team.

Description

The OCROptions.RecognitionRejectionThreshold property lets you specify whether to employ the custom threshold used to decide if the recognition of a character fails or not (this custom threshold is set via OCROptions.RecognitionRejection) or to use the character recognition threshold that is calculated automatically as described in Optical Character Recognition.

Declaration

OCROptionsObj.RecognitionRejectionAuto

Read-Write Property Boolean
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

True if the character recognition threshold will be calculated automatically. False if the custom character recognition threshold will be used.

Example

The following example sets the custom character recognition threshold value to 0.5 and recognizes characters written in Windows Notepad by using the specified recognition threshold. After that, it posts the recognized characters to the test log.

JavaScript, JScript

function OCROptionsSample()
{
  var notepad, Window, Rect, OCRObj, OCROptions;
  // 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();

  // Specifies that the custom character recognition threshold will be used
  OCROptions.RecognitionRejectionAuto = false;
  // Sets the custom character recognition threshold value
  OCROptions.RecognitionRejection = 0.5;
  // Recognizes the text and posts it to the test log

  Log.Message("Recognized 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()
  # Specifies that the custom character recognition threshold will be used
  OCROptions.RecognitionRejectionAuto = False
  # Sets the custom character recognition threshold value
  OCROptions.RecognitionRejection = 0.5
  # Recognizes the text and posts it to the test log
  Log.Message("Recognized 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

  ' Specifies that the custom character recognition threshold will be used
  OCROptions.RecognitionRejectionAuto = False
  ' Sets the custom character recognition threshold value
  OCROptions.RecognitionRejection = 0.5
  ' Recognizes the text and posts it to the test log

  Call Log.Message("Recognized characters:", OCRObj.GetText(OCROptions))
End Sub

DelphiScript

procedure OCROptionsSample();
var notepad, Window, Rect, OCRObj, OCROptions : OleVariant;
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;

  // Specifies that the custom character recognition threshold will be used
  OCROptions.RecognitionRejectionAuto := false;
  // Sets the custom character recognition threshold value
  OCROptions.RecognitionRejection := 0.5;
  // Recognizes the text and posts it to the test log

  Log.Message('Recognized characters:', OCRObj.GetText(OCROptions));
end;

C++Script, C#Script

function OCROptionsSample()
{
  var notepad, Window, Rect, OCRObj, OCROptions;
  // 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"]();

  // Specifies that the custom character recognition threshold will be used
  OCROptions["RecognitionRejectionAuto"] = false;
  // Sets the custom character recognition threshold value
  OCROptions["RecognitionRejection"] = 0.5;
  // Recognizes the text and posts it to the test log

  Log["Message"]("Recognized characters:", OCRObj["GetText"](OCROptions));
}

See Also

OCROptions.RecognitionRejection
OCROptions.GrayScaleBinarization
Optical Character Recognition
Using Optical Character Recognition - Tips

Highlight search results