StarRailCopilot/dev_tools/relative_crop.py

41 lines
906 B
Python
Raw Normal View History

2020-06-13 11:26:09 +00:00
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 = ''
2020-06-13 11:26:09 +00:00
# Put Screenshot here
file = ''
2020-06-13 11:26:09 +00:00
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)