Ejemplo n.º 1
0
def treasure_trove(frame, prev_state):
    global item_count
    cv2.imwrite('items/{}.png'.format(item_count),
                pos.get(frame, 'dialog_box'))
    item_count += 1

    press_button('x')
    return ["play_again"]
Ejemplo n.º 2
0
def get(img):
    cards = []

    for i in range(0, pos.get_num('cards')):
        card_img = pos.get(
            img, 'cards', i)  # img[pos[1]:pos[1]+dim[1], pos[0]:pos[0]+dim[0]]
        cards.append(least_diff(card_img, _cards))

    return cards
Ejemplo n.º 3
0
def get(img, multiplier):
    num_win_types = pos.get_num('got_hands')

    for i in range(0, num_win_types):
        hand_region = pos.get(img, 'got_hands', i)
        yes_diff = cv2.absdiff(hand_region, yes).mean()
        no_diff = cv2.absdiff(hand_region, no).mean()

        if yes_diff < 80 and no_diff > 80:
            return [win_types[i][0], win_types[i][1] * multiplier]

    return None
Ejemplo n.º 4
0
def obtain_item(frame, prev_state):
    global item_count, captured_item
    # store the item
    if not captured_item:
        captured_item = True
        cv2.imwrite('items/{}.png'.format(item_count),
                    pos.get(frame, 'dialog_box'))
        item_count += 1

    press_button('wait')
    press_button('x')

    return ['play_again']
Ejemplo n.º 5
0
def get(frame):
    roi = pos.get(frame, 'tokens')
    roi = cv2.resize(roi, (0, 0), fx=3, fy=3)

    lower = (0, 0, 0, 0) if frame.shape[2] == 4 else (0, 0, 0)
    upper = (150, 150, 150, 255) if frame.shape[2] == 4 else (150, 150, 150)

    output = cv2.inRange(roi, lower, upper)
    value = pytesseract.image_to_string(Image.fromarray(output))
    try:
        return int(value)
    except:
        return None
Ejemplo n.º 6
0
def get(img):
    print('state.get')
    diffs = []

    for state in states:
        roi = pos.get(img, 'states', state)

        mean = cv2.absdiff(state_images[state], roi).mean()
        diff = [mean, state]
        diffs.append(diff)

    diffs.sort(key=lambda x: x[0])

    if diffs[0][0] < 30:
        return diffs[0][1]

    return None