airtest.core.cv module

“Airtest图像识别专用.

loop_find(*args, **kwargs)[source]

Search for image template in the screen until timeout

Parameters:
  • query – image template to be found in screenshot
  • timeout – time interval how long to look for the image template
  • threshold – default is None
  • interval – sleep interval before next attempt to find the image template
  • intervalfunc – function that is executed after unsuccessful attempt to find the image template
Raises:

TargetNotFoundError – when image template is not found in screenshot

Returns:

TargetNotFoundError if image template not found, otherwise returns the position where the image template has been found in screenshot

try_log_screen(*args, **kwargs)[source]

Save screenshot to file

Parameters:screen – screenshot to be saved
Returns:None
class Template(filename, threshold=None, target_pos=5, record_pos=None, resolution=(), rgb=False)[source]

Bases: object

picture as touch/swipe/wait/exists target and extra info for cv match filename: pic filename target_pos: ret which pos in the pic record_pos: pos in screen when recording resolution: screen resolution when recording rgb: 识别结果是否使用rgb三通道进行校验.

filepath
match_in(screen)[source]
match_all_in(screen)[source]
class Predictor[source]

Bases: object

this class predicts the press_point and the area to search im_search.

DEVIATION = 100
static count_record_pos(pos, resolution)[source]

计算坐标对应的中点偏移值相对于分辨率的百分比.

classmethod get_predict_point(record_pos, screen_resolution)[source]

预测缩放后的点击位置点.

classmethod get_predict_area(record_pos, image_wh, image_resolution=(), screen_resolution=())[source]

Get predicted area in screen.