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 OCRObject.DefaultOptions
property returns an OCROptions
object that holds the default values of character recognition settings. Passing this object to the FindRectByText
or GetText
method discards the changes made via the CreateOptions
method.
Declaration
OCRObjectObj.DefaultOptions
Read-Only Property | An OCROptions object |
OCRObjectObj | An expression, variable or parameter that specifies a reference to an OCRObject object |
Applies To
The property is applied to the following object:
Property Value
An OCROptions
object holding the default values of character recognition settings.
Example
The following code snippet creates an OCROptions
object that contains the default character recognition settings and then posts those default settings to the test log.
JavaScript, JScript
function OCROptionsSample()
{
var OnScreenObj, Rect, OCRObj, OCROptions, Info, Fonts, Count;
// Obtains an on-screen object (Notepad window)
OnScreenObj = Sys.Process("notepad").Window("Notepad", "*").Window("Edit");
// Obtains an image of the on-screen object
Rect = OnScreenObj.Picture();
// Creates an OCR object
OCRObj = OCR.CreateObject(Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions = OCRObj.DefaultOptions;
// Obtains the default settings and posts them to the test log
Info = "Active recognition set: " + OCROptions.ActiveRecognitionSet + "\r\n"+
"Grayscale binarization: " + OCROptions.GrayScaleBinarization + "\r\n" +
"Binarization threshold: " + OCROptions.BinarizationThreshold + "\r\n" +
"Recognition autorejection: " + OCROptions.RecognitionRejectionAuto + "\r\n" +
"Recognition rejection threshold: " + OCROptions.RecognitionRejection + "\r\n" +
"Exact search is used: " + OCROptions.ExactSearch + "\r\n" +
"Search accuracy threshold: " + OCROptions.SearchAccuracy + "\r\n" +
"Skip fragmentation: " + OCROptions.SkipFragmentation;
Log.Message("Character Recognition Default Settings", Info);
…
}
{
var OnScreenObj, Rect, OCRObj, OCROptions, Info, Fonts, Count;
// Obtains an on-screen object (Notepad window)
OnScreenObj = Sys.Process("notepad").Window("Notepad", "*").Window("Edit");
// Obtains an image of the on-screen object
Rect = OnScreenObj.Picture();
// Creates an OCR object
OCRObj = OCR.CreateObject(Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions = OCRObj.DefaultOptions;
// Obtains the default settings and posts them to the test log
Info = "Active recognition set: " + OCROptions.ActiveRecognitionSet + "\r\n"+
"Grayscale binarization: " + OCROptions.GrayScaleBinarization + "\r\n" +
"Binarization threshold: " + OCROptions.BinarizationThreshold + "\r\n" +
"Recognition autorejection: " + OCROptions.RecognitionRejectionAuto + "\r\n" +
"Recognition rejection threshold: " + OCROptions.RecognitionRejection + "\r\n" +
"Exact search is used: " + OCROptions.ExactSearch + "\r\n" +
"Search accuracy threshold: " + OCROptions.SearchAccuracy + "\r\n" +
"Skip fragmentation: " + OCROptions.SkipFragmentation;
Log.Message("Character Recognition Default Settings", Info);
…
}
Python
def OCROptionsSample():
# Obtains an on-screen object (Notepad window)
OnScreenObj = Sys.Process("notepad").Window("Notepad", "*").Window("Edit")
# Obtains an image of the on-screen object
Rect = OnScreenObj.Picture()
# Creates an OCR object
OCRObj = OCR.CreateObject(Rect)
# Creates an OCROptions object that stores the default character recognition settings
OCROptions = OCRObj.DefaultOptions
# Obtains the default settings and posts them to the test log
Info = "Active recognition set: " + str(OCROptions.ActiveRecognitionSet) + "\r\n" + "Grayscale binarization: " + str(OCROptions.GrayScaleBinarization) + "\r\n" + "Binarization threshold: " + str(OCROptions.BinarizationThreshold) + "\r\n" + "Recognition autorejection: " + str(OCROptions.RecognitionRejectionAuto) + "\r\n" + "Recognition rejection threshold: " + str(OCROptions.RecognitionRejection) + "\r\n" + "Exact search is used: " + str(OCROptions.ExactSearch) + "\r\n" + "Search accuracy threshold: " + str(OCROptions.SearchAccuracy) + "\r\n" + "Skip fragmentation: " + str(OCROptions.SkipFragmentation)
Log.Message("Character Recognition Default Settings", Info)
VBScript
Sub OCROptionsSample
' Obtains an on-screen object (Notepad window)
Set OnScreenObj = Sys.Process("notepad").Window("Notepad", "*").Window("Edit")
' Obtains an image of the on-screen object
Set Rect = OnScreenObj.Picture
' Creates an OCR object
Set OCRObj = OCR.CreateObject(Rect)
' Creates an OCROptions object that stores the default character recognition settings
Set OCROptions = OCRObj.DefaultOptions
' Obtains the default settings and posts them to the test log
Info = "Active recognition set: " & OCROptions.ActiveRecognitionSet & VbCrLf & _
"Grayscale binarization: " & OCROptions.GrayScaleBinarization & VbCrLf & _
"Binarization threshold: " & OCROptions.BinarizationThreshold & VbCrLf & _
"Recognition autorejection: " & OCROptions.RecognitionRejectionAuto & VbCrLf & _
"Recognition rejection threshold: " & OCROptions.RecognitionRejection & VbCrLf & _
"Exact search is used: " & OCROptions.ExactSearch & VbCrLf & _
"Search accuracy threshold: " & OCROptions.SearchAccuracy & VbCrLf & _
"Skip fragmentation: " & OCROptions.SkipFragmentation
Call Log.Message("Character Recognition Default Settings", Info)
…
End Sub
' Obtains an on-screen object (Notepad window)
Set OnScreenObj = Sys.Process("notepad").Window("Notepad", "*").Window("Edit")
' Obtains an image of the on-screen object
Set Rect = OnScreenObj.Picture
' Creates an OCR object
Set OCRObj = OCR.CreateObject(Rect)
' Creates an OCROptions object that stores the default character recognition settings
Set OCROptions = OCRObj.DefaultOptions
' Obtains the default settings and posts them to the test log
Info = "Active recognition set: " & OCROptions.ActiveRecognitionSet & VbCrLf & _
"Grayscale binarization: " & OCROptions.GrayScaleBinarization & VbCrLf & _
"Binarization threshold: " & OCROptions.BinarizationThreshold & VbCrLf & _
"Recognition autorejection: " & OCROptions.RecognitionRejectionAuto & VbCrLf & _
"Recognition rejection threshold: " & OCROptions.RecognitionRejection & VbCrLf & _
"Exact search is used: " & OCROptions.ExactSearch & VbCrLf & _
"Search accuracy threshold: " & OCROptions.SearchAccuracy & VbCrLf & _
"Skip fragmentation: " & OCROptions.SkipFragmentation
Call Log.Message("Character Recognition Default Settings", Info)
…
End Sub
DelphiScript
procedure OCROptionsSample();
var
OnScreenObj, Rect, OCRObj, OCROptions, Fonts : OleVariant;
Info : string;
i, Count : integer;
begin
// Obtains an on-screen object (Notepad window)
OnScreenObj := Sys.Process('notepad').Window('Notepad', '*').Window('Edit');
// Obtains an image of the on-screen object
Rect := OnScreenObj.Picture;
// Creates an OCR object
OCRObj := OCR.CreateObject(Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions := OCRObj.DefaultOptions;
// Obtains the default settings and posts them to the test log
Info := 'Active recognition set: ' + aqConvert.IntToStr(OCROptions.ActiveRecognitionSet) + #13#10+
'Grayscale binarization: ' + aqConvert.VarToStr(OCROptions.GrayScaleBinarization) + #13#10 +
'Binarization threshold: ' + aqConvert.IntToStr(OCROptions.BinarizationThreshold) + #13#10 +
'Recognition autorejection: ' + aqConvert.VarToStr(OCROptions.RecognitionRejectionAuto) + #13#10 +
'Recognition rejection threshold: ' + aqConvert.FloatToStr(OCROptions.RecognitionRejection) + #13#10 +
'Exact search is used: ' + aqConvert.VarToStr(OCROptions.ExactSearch) + #13#10 +
'Search accuracy threshold: ' + aqConvert.FloatToStr(OCROptions.SearchAccuracy) + #13#10 +
'Skip fragmentation: ' + aqConvert.VarToStr(OCROptions.SkipFragmentation);
Log.Message('Character Recognition Default Settings', Info);
…
end;
var
OnScreenObj, Rect, OCRObj, OCROptions, Fonts : OleVariant;
Info : string;
i, Count : integer;
begin
// Obtains an on-screen object (Notepad window)
OnScreenObj := Sys.Process('notepad').Window('Notepad', '*').Window('Edit');
// Obtains an image of the on-screen object
Rect := OnScreenObj.Picture;
// Creates an OCR object
OCRObj := OCR.CreateObject(Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions := OCRObj.DefaultOptions;
// Obtains the default settings and posts them to the test log
Info := 'Active recognition set: ' + aqConvert.IntToStr(OCROptions.ActiveRecognitionSet) + #13#10+
'Grayscale binarization: ' + aqConvert.VarToStr(OCROptions.GrayScaleBinarization) + #13#10 +
'Binarization threshold: ' + aqConvert.IntToStr(OCROptions.BinarizationThreshold) + #13#10 +
'Recognition autorejection: ' + aqConvert.VarToStr(OCROptions.RecognitionRejectionAuto) + #13#10 +
'Recognition rejection threshold: ' + aqConvert.FloatToStr(OCROptions.RecognitionRejection) + #13#10 +
'Exact search is used: ' + aqConvert.VarToStr(OCROptions.ExactSearch) + #13#10 +
'Search accuracy threshold: ' + aqConvert.FloatToStr(OCROptions.SearchAccuracy) + #13#10 +
'Skip fragmentation: ' + aqConvert.VarToStr(OCROptions.SkipFragmentation);
Log.Message('Character Recognition Default Settings', Info);
…
end;
C++Script, C#Script
function OCROptionsSample()
{
var OnScreenObj, Rect, OCRObj, OCROptions, Info, Fonts, Count;
// Obtains an on-screen object (Notepad window)
OnScreenObj = Sys["Process"]("notepad")["Window"]("Notepad", "*")["Window"]("Edit");
// Obtains an image of the on-screen object
Rect = OnScreenObj["Picture"]();
// Creates an OCR object
OCRObj = OCR["CreateObject"](Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions = OCRObj["DefaultOptions"];
// Obtains the default settings and posts them to the test log
Info = "Active recognition set: " + OCROptions["ActiveRecognitionSet"] + "\r\n"+
"Grayscale binarization: " + OCROptions["GrayScaleBinarization"] + "\r\n" +
"Binarization threshold: " + OCROptions["BinarizationThreshold"] + "\r\n" +
"Recognition autorejection: " + OCROptions["RecognitionRejectionAuto"] + "\r\n" +
"Recognition rejection threshold: " + OCROptions["RecognitionRejection"] + "\r\n" +
"Exact search is used: " + OCROptions["ExactSearch"] + "\r\n" +
"Search accuracy threshold: " + OCROptions["SearchAccuracy"] + "\r\n" +
"Skip fragmentation: " + OCROptions["SkipFragmentation"];
Log.Message("Character Recognition Default Settings", Info);
…
}
{
var OnScreenObj, Rect, OCRObj, OCROptions, Info, Fonts, Count;
// Obtains an on-screen object (Notepad window)
OnScreenObj = Sys["Process"]("notepad")["Window"]("Notepad", "*")["Window"]("Edit");
// Obtains an image of the on-screen object
Rect = OnScreenObj["Picture"]();
// Creates an OCR object
OCRObj = OCR["CreateObject"](Rect);
// Creates an OCROptions object that stores the default character recognition settings
OCROptions = OCRObj["DefaultOptions"];
// Obtains the default settings and posts them to the test log
Info = "Active recognition set: " + OCROptions["ActiveRecognitionSet"] + "\r\n"+
"Grayscale binarization: " + OCROptions["GrayScaleBinarization"] + "\r\n" +
"Binarization threshold: " + OCROptions["BinarizationThreshold"] + "\r\n" +
"Recognition autorejection: " + OCROptions["RecognitionRejectionAuto"] + "\r\n" +
"Recognition rejection threshold: " + OCROptions["RecognitionRejection"] + "\r\n" +
"Exact search is used: " + OCROptions["ExactSearch"] + "\r\n" +
"Search accuracy threshold: " + OCROptions["SearchAccuracy"] + "\r\n" +
"Skip fragmentation: " + OCROptions["SkipFragmentation"];
Log.Message("Character Recognition Default Settings", Info);
…
}
See Also
FindRectByText Method
GetText Method
CreateOptions Method
Using Optical Character Recognition - Tips