adb_image_cv

class adb_image_cv.AdbImageCV(adb: ~adb_tool_py.adb_command.AdbCommand = <adb_tool_py.adb_command.AdbCommand object>)[source]

Bases: object

A class to capture and process images from an Android device using ADB and OpenCV.

capture() None[source]

Captures the current screen of the connected Android device and stores it as an OpenCV image.

check_image(image_path: str, index: int = 0, is_capture: bool = False, match_threshold: float = 0.99, merge_threshold: int = 10) bool[source]

Checks if the specified image is present on the screen.

Parameters:
  • image_path – Path to the image file to search for.

  • index – Index of the matching image rectangle to use, defaults to 0.

  • is_capture – Whether to capture the screen before searching, defaults to False.

  • match_threshold – Threshold for image matching, defaults to 0.99.

  • merge_threshold – Threshold for merging close rectangles, defaults to 10.

Returns:

True if the image is found, False otherwise.

find_image(image_path: str, index: int = 0, is_capture: bool = False, match_threshold: float = 0.99, merge_threshold: int = 10) tuple[int, int, int, int] | None[source]

Finds the specified image on the screen and returns the rectangle of the match.

Parameters:
  • image_path – Path to the image file to search for.

  • index – Index of the matching image rectangle to return, defaults to 0.

  • is_capture – Whether to capture the screen before searching, defaults to False.

  • match_threshold – Threshold for image matching, defaults to 0.99.

  • merge_threshold – Threshold for merging close rectangles, defaults to 10.

Returns:

The rectangle of the found image, or None if not found.

find_images(image_path: str, is_capture: bool = False, match_threshold: float = 0.99, merge_threshold: int = 10) list[tuple[int, int, int, int]][source]

Finds instances of a specified image within the captured screen image.

Parameters:
  • image_path – Path to the image file to search for.

  • is_capture – Whether to capture the screen before searching, defaults to False.

  • match_threshold – Threshold for image matching, defaults to 0.99.

  • merge_threshold – Threshold for merging close rectangles, defaults to 10.

Returns:

A list of rectangles where the image was found.

set_capture(image_path: str) None[source]

Sets the current capture from a specified image file path.

Parameters:

image_path – Path to the image file.

touch_image(image_path: str, index: int = 0, is_capture: bool = False, match_threshold: float = 0.99, merge_threshold: int = 10) bool[source]

Simulates a tap on the screen at the center of the specified image if found.

Parameters:
  • image_path – Path to the image file to search for.

  • index – Index of the matching image rectangle to use, defaults to 0.

  • is_capture – Whether to capture the screen before searching, defaults to False.

  • match_threshold – Threshold for image matching, defaults to 0.99.

  • merge_threshold – Threshold for merging close rectangles, defaults to 10.

Raises:

ValueError – If the image is not found.