Image API
Functions for image recognition using OpenCV template matching.
locate_all_image
- je_auto_control.locate_all_image(image, detect_threshold=1, draw_image=False)
Locates all occurrences of a template image on the screen.
- Parameters:
image (str or PIL.Image) – Template image to search for (file path or PIL image).
detect_threshold (float) – Detection precision from
0.0to1.0.1.0requires an exact match.draw_image (bool) – If
True, marks detected areas on the returned image.
- Returns:
List of bounding boxes
[[x1, y1, x2, y2], ...].- Return type:
list[list[int]]
locate_image_center
- je_auto_control.locate_image_center(image, detect_threshold=1, draw_image=False)
Locates a template image and returns its center position.
- Parameters:
image (str or PIL.Image) – Template image to search for (file path or PIL image).
detect_threshold (float) – Detection precision from
0.0to1.0.draw_image (bool) – If
True, marks detected areas on the returned image.
- Returns:
Center coordinates
(x, y).- Return type:
list[int, int]
locate_and_click
- je_auto_control.locate_and_click(image, mouse_keycode, detect_threshold=1, draw_image=False)
Locates a template image and clicks on its center position.
- Parameters:
image (str or PIL.Image) – Template image to search for (file path or PIL image).
mouse_keycode (int or str) – Mouse button to click (e.g.,
"mouse_left").detect_threshold (float) – Detection precision from
0.0to1.0.draw_image (bool) – If
True, marks detected areas on the returned image.
- Returns:
Center coordinates
(x, y)of the clicked image.- Return type:
list[int, int]
screenshot
- je_auto_control.screenshot(file_path=None, region=None)
Captures the current screen.
- Parameters:
file_path (str) – Path to save the screenshot. If
None, the image is not saved to disk.region (list) – Screen region to capture as
[x1, y1, x2, y2]. IfNone, captures the full screen.
- Returns:
The captured screen image.
- Return type:
PIL.Image