예제 #1
0
파일: main.py 프로젝트: Codehimn/CCrush-Bot
def grab_board():
    global game_board
    img = ImageGrab.grab()

    # img = Image.open('board.bmp')
    img = img.crop(board_box)
    # img.save('board.bmp')
    for y in range(0, 9):
        for x in range(0, 9):
            cell_box = (x * cell_size[0], y * cell_size[1], (x + 1) * cell_size[0], (y + 1) * cell_size[1])
            cell = img.crop(cell_box)
            # cell.save('Cells_{0}_{1}.bmp'.format(y, x))
            game_board[y][x] = recognizer.predict(cell)
    dbg.print_board(game_board)
    return img
예제 #2
0
def grab_board():
    global game_board
    os.system("screencapture -t bmp ./image.bmp")
    img = Image.open("./image.bmp")
    #    img = Image.open('board.bmp')
    img = img.crop(board_box)
    img.save("image_debug_after_crop_grab.bmp")
    for y in range(0, 9):
        for x in range(0, 9):
            cell_box = (x * cell_size[0], y * cell_size[1], (x + 1) * cell_size[0], (y + 1) * cell_size[1])
            cell = img.crop(cell_box)
            # cell.save('Cells/{0}_{1}.bmp'.format(y, x))
            game_board[y][x] = recognizer.predict(cell)

    dbg.print_board(game_board)
    return img
예제 #3
0
def grab_board():
    global game_board
    img = ImageGrab.grab()

    #img = Image.open('board.bmp')
    img = img.crop(board_box)
    #img.save('board.bmp')
    for y in range(0, 9):
        for x in range(0, 9):
            cell_box = (x*cell_size[0], y*cell_size[1], (x+1)*cell_size[0], (y+1)*cell_size[1])
            cell = img.crop(cell_box)
            #cell.save('Cells/{0}_{1}.bmp'.format(y, x))
            game_board[y][x] = recognizer.predict(cell)

    dbg.print_board(game_board)
    return img