def parse_drop(self, file):
        """
        Parse a single file.

        Args:
            file (str):

        Yields:
            list: [timestamp, campaign, enemy_name, drop_type, item, amount]
        """
        ts = os.path.splitext(os.path.basename(file))[0]
        campaign = os.path.basename(os.path.abspath(os.path.join(file, '../')))
        images = unpack(load_image(file))
        enemy_name = 'unknown'
        for image in images:
            if self.battle_status.appear_on(image):
                enemy_name = self.battle_status.stats_battle_status(image)
            if self.get_items.appear_on(image):
                for item in self.get_items.stats_get_items(image):
                    yield [
                        ts, campaign, enemy_name, 'GET_ITEMS', item.name,
                        item.amount
                    ]
            if self.campaign_bonus.appear_on(image):
                for item in self.campaign_bonus.stats_get_items(image):
                    yield [
                        ts, campaign, enemy_name, 'CAMPAIGN_BONUS', item.name,
                        item.amount
                    ]
Esempio n. 2
0
    def image(self):
        if self._image is None:
            image = load_image(self.file)
            if image_channel(image) == 3:
                image = rgb2gray(image)
            self._image = image

        return self._image
 def parse_template(self, file):
     """
     Extract template from a single file.
     New templates will be given an auto-increased ID.
     """
     images = unpack(load_image(file))
     for image in images:
         if self.get_items.appear_on(image):
             self.get_items.extract_template(image,
                                             folder=self.template_folder)
         if self.campaign_bonus.appear_on(image):
             self.campaign_bonus.extract_template(
                 image, folder=self.template_folder)
Esempio n. 4
0
 def extract(self, file):
     if os.path.splitext(file)[1] == '.gif':
         # In a gif Button, use the first image.
         bbox = None
         mean = None
         for image in imageio.mimread(file):
             image = image[:, :, :3] if len(image.shape) == 3 else image
             new_bbox, new_mean = self._extract(image, file)
             if bbox is None:
                 bbox = new_bbox
             elif bbox != new_bbox:
                 logger.warning(
                     f'{file} has multiple different bbox, this will cause unexpected behaviour'
                 )
             if mean is None:
                 mean = new_mean
         return bbox, mean
     else:
         image = load_image(file)
         return self._extract(image, file)
Esempio n. 5
0
 def extract(file):
     image = load_image(file)
     bbox = get_bbox(image)
     mean = get_color(image=image, area=bbox)
     mean = tuple(np.rint(mean).astype(int))
     return bbox, mean
class Config:
    """
    Paste the config of map file here
    """
    pass

from module.os.config import OSConfig
cfg = AzurLaneConfig('alas').merge(OSConfig())

# Folder to save temp images
folder = './screenshots/relative_crop'
# Put Screenshot here
file = ''

i = load_image(file)
grids = View(cfg)
grids.load(np.array(i))
grids.predict()
grids.show()


os.makedirs(folder, exist_ok=True)
for grid in grids:
    # Find more relative_crop area in module/map/grid_predictor.py
    # This one is for `predict_enemy_genre`
    piece = rgb2gray(grid.relative_crop((-0.5, -1, 0.5, 0), shape=(60, 60)))

    file = '%s_%s_%s.png' % (int(time.time()), grid.location[0], grid.location[1])
    file = os.path.join(folder, file)
    Image.fromarray(piece).save(file)