TextRegionSettings method
Define a list of string literals or patterns to be searched for using OCR using the Eyes.extract_text_regions method.
Create an object of this type is used to pass options to Eyes.extract_text_regions. Typically you call the class constructor, and then call the methods of this class chained in a Fluent API style to set the required options.
For more information see Eyes OCR support .
This feature is experimental. Please note that the functionality and/or API may change.
Syntax
obj = TextRegionSettings(patterns)
Parameters
- patterns
- Type:*Union[Text,List[Text]]
- One or more strings that that can be literal text or a regular expression like pattern that defines what text to search for. See the remarks section for details of how to define patterns.
Return value
- Type: None
- This method returns the object that called it so that it can be used to call other methods supportd by this class in a fluent API style.
Remarks
Defining Patterns and Hints
An OCR pattern/hint may be composed of any of the following characters:
. | Matches any character. |
\d | Matches any digit 0-9. |
\l | (Lowercase L) Matches any letter a-z or A-Z. |
\w | Matches any word character a-z, A-Z, or _. |
\S | Matches any non-space character. |
+ | Repeats the previous literal character or character class one or more times, for example, "\d+" is any multi-numeral digit and "\w+" is any word that contains only letters or an underscore. This pattern cannot cross a line break. |
\ | Escapes a character that has a special meaning – specifically use this to specify the literals "\", ".", and "+" by using " \\", "\", and "\+". |
space | The OCR is tolerant of spaces between characters, so you don’t have to add them to the pattern. Where a space is detected in the image, it is translated into a single space. If you add an explicit space in the pattern, then it matches any number of spaces. |
Any other character represents itself. |
Depending on the programming language you use, the back-slashed character classes may need to be specially encoded in the string, for example, by using a double back-slash such as "\\w".
Example patterns
-
"\w+": Match a word
-
"\d+": Match a number
-
"\S+" : Match mixed alphabetic and digital data
-
"\d+/\d+/\d+": Match a date, such as 01/04/1972
-
"$\d+.\d+": Match an amount of money, such as $150.00