Text Reader

Read text on the screen into a variable

How it works

Select the Region and text will be read using OCR technology.

The result will be set to a variable.

What you do with the variable is up to you. You can use Conditional and check if that text contains some word or compare if it's a number.

How to Create

Using the icon in Bottombar.

Region

This is the area to read the text. Same as a detection

Correction
Correction

OCR is not perfect, some font might give it a hard time and produce incorrect text ("I" and "l" look quite the same). That's where you need to "correct" it.

You can add many corrections. There are 3 type of correction: Find&Replace, Whitelist and Blacklist:

  • Find&Replace: Find characters in From and replace with To. There are two mode you can use:
    • Simple: Simple find and replace. The characters in From will be replaced with To when found. Auto escape ", \
    • Regex: Advanced users will have access to regular expression allowing powerful text find and replace. Make sure to escape special characters
  • Whitelist: Only characters in this list are retained. The rest will be removed.
  • Blacklist: Characters in this list will be removed.
Result
Correction

This is where you select the variable to set.

The result of the Text Reader will be written as a string.

Select Convert to number will attempt to convert the string into a number.

If conversion fails (string is not a number or text cannot be read) then the default value is returned if set or null.

Note: If you use a Conditional to compare the text (greater, lesser, etc...) then it automatically converts your text into a number. You only need to explicitly convert to number when you want to do arithmetic on it (plus, minus, etc...).

Code Equivalent

    //Create a Region
    var region = Region(x, y, w, h)

    //Read from the region
    var text = region.readAsString()

    if (text) {
        //Do something with the text    
    }

© 2022 - Macrorify by KoK-CODE