guibot.target module¶
SUMMARY¶
Classes and functionality related to sought targets on screen.
INTERFACE¶
-
class
guibot.target.
Target
(match_settings=None)[source]¶ Bases:
object
Target used to obtain screen location for clicking, typing, validation of expected visual output, etc.
-
static
from_data_file
(filename)[source]¶ Read the target type from the extension of the target filename.
Parameters: filename (str) – data filename for the target Returns: target of type determined from its data filename extension Return type: target.Target
Raises: errors.IncompatibleTargetFileError
if the data file if of unknown type
-
static
from_match_file
(filename)[source]¶ Read the target type and configuration from a match file with the given filename.
Parameters: filename (str) – match filename for the configuration Returns: target of type determined from its parsed (and generated) settings Return type: target.Target
-
__init__
(match_settings=None)[source]¶ Build a target object.
Parameters: match_settings ( finder.Finder
or None) – predefined configuration for the CV backend if any
-
similarity
¶ Getter for readonly attribute.
Returns: similarity required for the image to be matched Return type: float
-
center_offset
¶ Getter for readonly attribute.
Returns: offset with respect to the target center (used for clicking) Return type: location.Location
This clicking location is set in the target in order to be customizable, it is then taken when matching to produce a clicking target for a match.
-
load
(filename, **kwargs)[source]¶ Load target from a file.
Parameters: filename (str) – name for the target file If no local file is found, we will perform search in the previously added paths.
-
copy
()[source]¶ Perform a copy of the target data and match settings.
Returns: copy of the current target (with settings) Return type: target.Target
-
with_center_offset
(xpos, ypos)[source]¶ Perform a copy of the target data with new match settings and with a newly defined center offset.
Parameters: - xpos (int) – new offset in the x direction
- ypos (int) – new offset in the y direction
Returns: copy of the current target with new center offset
Return type: target.Target
-
static
-
class
guibot.target.
Image
(image_filename=None, pil_image=None, match_settings=None, use_cache=True)[source]¶ Bases:
guibot.target.Target
Container for image data supporting caching, clicking target, file operations, and preprocessing.
-
__init__
(image_filename=None, pil_image=None, match_settings=None, use_cache=True)[source]¶ Build an image object.
Parameters: - image_filename (str or None) – name of the image file if any
- pil_image (
PIL.Image
or None) – image data - use cache or recreate if none - match_settings (
finder.Finder
or None) – predefined configuration for the CV backend if any - use_cache (bool) – whether to cache image data for better performance
-
filename
¶ Getter for readonly attribute.
Returns: filename of the image Return type: str
-
width
¶ Getter for readonly attribute.
Returns: width of the image Return type: int
-
height
¶ Getter for readonly attribute.
Returns: height of the image Return type: int
-
pil_image
¶ Getter for readonly attribute.
Returns: image data of the image Return type: PIL.Image
-
-
class
guibot.target.
Text
(value=None, text_filename=None, match_settings=None)[source]¶ Bases:
guibot.target.Target
Container for text data which is visually identified using OCR or general text detection methods.
-
__init__
(value=None, text_filename=None, match_settings=None)[source]¶ Build a text object.
Parameters: - value (str) – text value to search for
- text_filename (str) – custom filename to read the text from
- match_settings (
finder.Finder
or None) – predefined configuration for the CV backend if any
-
-
class
guibot.target.
Pattern
(id, match_settings=None)[source]¶ Bases:
guibot.target.Target
Container for abstracted data which is obtained from training of a classifier in order to recognize a target.
-
__init__
(id, match_settings=None)[source]¶ Build a pattern object.
Parameters: - id (str) – alphanumeric id of logit or label for the given pattern
- match_settings (
finder.Finder
or None) – predefined configuration for the CV backend if any
-
-
class
guibot.target.
Chain
(target_name, match_settings=None)[source]¶ Bases:
guibot.target.Target
Container for multiple configurations representing the same target.
The simplest version of a chain is a sequence of the same match configuration steps performed on a sequence of images until one of them succeeds. Every next step in this chain is a fallback case if the previous step did not succeed.
-
__init__
(target_name, match_settings=None)[source]¶ Build an chain object.
Parameters: - target_name (str) – name of the target for all steps
- match_settings (
finder.Finder
or None) – predefined configuration for the CV backend if any
-