예제 #1
0
def check_equipment(image, template_path):
    """
    查找装备
    :param template_path: 模板目录
    :return: {'r': 相似度, 'x': x坐标, 'y': y坐标, 'path': 模板路径}
    """
    THRESHOLD = 0.55
    found = None
    return_list = list()

    screen = image
    # 遍历所有的图片寻找模板
    for imagePath in glob.glob(template_path + "/*"):
        log.debug("> " + imagePath)
        # result = UIMatcher.multi_scale_template_match(screen, imagePath)
        h, w = screen.shape[:2]
        item_w = w / 10
        scale = 128 / item_w
        result = UIMatcher.multi_scale_template_match(
            screen, imagePath, min_scale=scale, max_scale=scale, step=1)

        if result['r'] > THRESHOLD:
            result['path'] = imagePath
            return_list.append(result)

    return return_list
예제 #2
0
 def test_multi_scale_template_match(self):
     app = Automator()
     screenshot = app.d.screenshot(format="opencv")
     res = UIMatcher.multi_scale_template_match(screenshot, "../equipment_img/115011.webp")
     # res = UIMatcher.multi_scale_template_match(screenshot, "../tw_img/icon_guild.jpg")
     self.assertLessEqual(THRESHOLD, res['r'])
     self.assertLessEqual(0, res['x'])
     self.assertLessEqual(0, res['y'])
     print(res)