Exemple #1
0
def find_attack(card):
    attack_list = []
    for num in range(1, max_attack + 1):
        attack = fix(f'Hearthstone myndir/New folder/{num} attack.png')
        attack_list.append((num, get_max_val(card, attack)))
        if attack_list[-1][1] > satisfying:
            return attack_list[-1][0]

    print(attack_list)
    return closest_match(attack_list)
Exemple #2
0
def find_health(card, hero=False):
    if hero:
        max_hp = max_hero_health
    else:
        max_hp = max_health
    hp_list = []

    for num in range(1, max_hp + 1):
        hp = fix(f'Hearthstone myndir/New folder/{num} hp.png')
        hp_list.append((num, get_max_val(card, hp)))
        if hp_list[-1][1] > satisfying:
            return hp_list[-1][0]
    print(hp_list)
    return closest_match(hp_list)
def read_card(an_img):
    '''Returns the stats of a given card from its image.'''

    templates = ["Hearthstone myndir/New folder/1 mana.png","Hearthstone myndir/New folder/1 attack.png",\
        "Hearthstone myndir/New folder/1 hp (abusive) bigger.png"]

    for data_img in templates:
        data_img = fix(data_img)
        total = 0
        template = cv.imread(data_img,0)
        for meth in methods:
            method = eval(meth)
        # Apply template Matching
            res = cv.matchTemplate(image,template,method)
            min_val, max_val, min_loc, max_loc = cv.minMaxLoc(res)
            total += max_val
        if 0.9 < total/3 < 1.1:
            print(data_img[29:])
Exemple #4
0
    """ Accepts a list of tuples (stat, certainty) returns closest match """
    the_stat, min_delta = a_list[0][0], abs(a_list[0][1] - 1)

    for stat, match in a_list:
        if abs(match - 1) < min_delta:
            the_stat, min_delta = stat, abs(match - 1)

    return the_stat


def get_stats(image):
    return find_mana(image), find_attack(image), find_health(image)


import time

for i in range(-700, -670, 1):
    card_res += i
    the_card = fix('Hearthstone myndir/Damaged 2-2 board.png')
    # print(i, 'Stats:', find_mana(the_card),find_attack(the_card),find_health(the_card))
    print(i, find_attack(the_card), find_health(the_card))
    card_res -= i

# Miðað við 1080p þá virkaði -100 á argent í hand
# Miðað við 1080p þá virkaði -450 á argent í muligan   -440 nákvæmast
# Fyrir muligan: -440, virkaði fyrir argent, annoy og apprentice

# Miðað vip 1080p þá virkaði -690 og -680 á 2-1 minion á board, virkaði líka fyrir damaged 2-2 á board
# -685
# -684
# Sennilega nota -684
    for data_img in templates:
        data_img = fix(data_img)
        total = 0
        template = cv.imread(data_img,0)
        for meth in methods:
            method = eval(meth)
        # Apply template Matching
            res = cv.matchTemplate(image,template,method)
            min_val, max_val, min_loc, max_loc = cv.minMaxLoc(res)
            total += max_val
        if 0.9 < total/3 < 1.1:
            print(data_img[29:])



image = cv.imread(fix("Hearthstone myndir/Shattered sun cleric.png"),0)
image2 = image.copy()
template = cv.imread(fix('Hearthstone myndir/New folder/3 attack.png'),0)

cv.imshow('img',image)

print('gg')

total = 0
total_list = []
other_list = []

w, h = template.shape[::-1]
# All the 6 methods for comparison in a list
# methods = ['cv.TM_CCOEFF', 'cv.TM_CCOEFF_NORMED', 'cv.TM_CCORR',
            # 'cv.TM_CCORR_NORMED', 'cv.TM_SQDIFF', 'cv.TM_SQDIFF_NORMED']