Recognize Image Text or PDF
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
Recognizes and returns text contained in an image or PDF file obtained from a specified font.
You can use this command to leverage surface automation capabilities to your script. For more information, see Actions for surface automation.
Script syntax
IBM RPA's proprietary scripting language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
recognizeText --source(Image) --language(String) --method(OpticalCharacterRecognitionProvider) [--googlevisionclientsecret(String)] (String)=value (String)=error (Numeric)=confidence (Boolean)=success --sanitize(Boolean)
Input parameter
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Source | source |
Required |
Image, PDF, Text |
Image source location or PDF file for text recognition. See the source parameter options |
Recognize from file (Obsolete) | recognizefromfile |
Optional |
Optional |
When enabled, allows for the use of a file path. This parameter is obsolete, use the Source parameter instead. |
Method | method |
Required |
OpticalCharacterRecognitionProvider |
Text recognition method to use. See the method parameter options |
Sanitize | sanitize |
Only visible when the method parameter is Abbyy |
Boolean |
Removes the following Unicode characters from the returned match: \u2028 and \u2029 . |
API Parameters | googlevisionclientsecret |
Only visible when the method parameter is Google Cloud Vision |
Text |
The absolute path to the JSON file containing the API parameters. Refer to the Google Cloud Vision™ |
Image (Obsolete) | image |
Optional |
image |
Image asset used for text recognition. This parameter is obsolete, use the Source parameter instead. |
Language | language |
Required |
Text, Culture |
Language of the text that should be retrieved. For supported languages see Supported languages. The user can override the default supported languages with a valid culture code that is supported by the OCR provider. |
source
parameter options
The following table displays the options available for the source
input paramenter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Description |
---|---|
Full file path | Full file path to the file location. |
File URL | File URL to the file location. |
Variable of type Image , PDF or Text |
Variable types where the file location is stored. Remember:For
Text type, either full path or its URL is accepted. |
method
parameter options
The following table displays the options available for the method
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name | Description |
---|---|---|
Abbyy | Abbyy |
Abbyy OCR Provider. |
Google |
Google Tesseract OCR provider. | |
Google Cloud Vision | GoogleVision |
Google Cloud Vision API. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Success | success |
Boolean |
Returns true if the text was successfully obtained, or false otherwise. |
Value | text |
Text |
Text that was obtained. |
Error | error |
Text |
Percentage of error. |
Confidence | confidence |
Number |
Confidence level in obtaining the text. The value returned is from 0 to 1, with "1" being the maximum reliability and "0" being the minimum. |
Example
The command is used to recognize the text contained in a web image.
defVar --name recognizedText --type String
defVar --name confidenceResult --type Numeric
defVar --name recognizeSuccess --type Boolean
recognizeText --source "https://im.gifbt.com/event/88c82e008a850b5ce09ca700dbf1903/1573185686220/eventlogo-16-1573109420.jpg" --language "eng" --method "GoogleVision" recognizedText=value confidenceResult=confidence recognizeSuccess=success
logMessage --message "Confidence: ${confidenceResult}\r\nSuccess: ${recognizeSuccess}\r\nRecognized Text: ${recognizedText}" --type "Info"
// Result: Confidence: 0.914999961853027
// Success: True
// Recognized Text: TECHIES
// MEETUP
Limitations
When using Google Cloud Vision as the OCR provider, the command may fail if the image or PDF file is too bright.