StarRailCopilot/dev_tools/relative_crop.py
whoamikyo ce3b0be361 Revert "Merge branch 'dev' into master"
This reverts commit 56d2df66b9, reversing
changes made to 159304cdd0.
2020-06-16 15:54:44 -03:00

41 lines
906 B
Python

import os
from PIL import Image
import time
# os.chdir('../')
print(os.getcwd())
import module.config.server as server
server.server = 'cn' # Don't need to edit, it's used to avoid error.
from module.map.grids import Grids
from module.config.config import AzurLaneConfig
class Config:
"""
Paste the config of map file here
"""
pass
cfg = AzurLaneConfig().merge(Config())
# Folder to save temp images
folder = ''
# Put Screenshot here
file = ''
i = Image.open(file).convert('RGB')
grids = Grids(i, cfg)
grids.predict()
grids.show()
for grid in grids:
# Find more relative_crop area in module/map/grid_predictor.py
# This one is for `predict_enemy_genre`
piece = grid.get_relative_image((-1, -1, 1, 0), output_shape=(120, 60))
file = '%s_%s_%s.png' % (int(time.time()), grid.location[0], grid.location[1])
file = os.path.join(folder, file)
piece.save(file)