airtest.core.cv module

“Airtest图像识别专用.

loop_find(query, timeout=20, threshold=None, interval=0.5, intervalfunc=None)[源代码]

Search for image template in the screen until timeout

参数:
  • 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

抛出:

TargetNotFoundError – when image template is not found in screenshot

返回:

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

try_log_screen(screen=None, quality=None, max_size=None)[源代码]

Save screenshot to file

参数:
  • screen – screenshot to be saved

  • quality – The image quality, default is ST.SNAPSHOT_QUALITY

  • max_size – the maximum size of the picture, e.g 1200

返回:

filename, “resolution”: aircv.get_resolution(screen)}

返回类型:

{“screen”

class Template(filename, threshold=None, target_pos=5, record_pos=None, resolution=(), rgb=False, scale_max=800, scale_step=0.005)[源代码]

基类: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三通道进行校验. scale_max: 多尺度模板匹配最大范围. scale_step: 多尺度模板匹配搜索步长.

property filepath
match_in(screen)[源代码]
match_all_in(screen)[源代码]
class Predictor[源代码]

基类:object

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

DEVIATION = 100
static count_record_pos(pos, resolution)[源代码]

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

classmethod get_predict_point(record_pos, screen_resolution)[源代码]

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

classmethod get_predict_area(record_pos, image_wh, image_resolution=(), screen_resolution=())[源代码]

Get predicted area in screen.