From aa28452efec4d0279b340d5244eae16022bf5060 Mon Sep 17 00:00:00 2001 From: chrisoro Date: Tue, 20 Aug 2024 20:17:10 +0200 Subject: [PATCH] Shrink item type area --- src/item/data/item_type.py | 2 +- src/item/descr/item_type.py | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/item/data/item_type.py b/src/item/data/item_type.py index 6ec8f370..d846980f 100644 --- a/src/item/data/item_type.py +++ b/src/item/data/item_type.py @@ -29,8 +29,8 @@ class ItemType(Enum): Sword2H = "two-handed sword" Tome = "tome" Wand = "wand" - TemperManual = "temper manual" # Custom Types Incense = "incense" Material = "material" Sigil = "sigil" + TemperManual = "temper manual" diff --git a/src/item/descr/item_type.py b/src/item/descr/item_type.py index 284f950c..329aa880 100644 --- a/src/item/descr/item_type.py +++ b/src/item/descr/item_type.py @@ -11,12 +11,8 @@ def read_item_type( item: Item, img_item_descr: np.ndarray, sep_short_match: TemplateMatch, do_pre_proc: bool = True ) -> tuple[Item | None, str]: - # Item Type and Item Power - # ===================================== - # start_power = time.time() - rarity = item.rarity _, img_width, _ = img_item_descr.shape - roi_top = [0, 0, int(img_width * 0.74), sep_short_match.center[1]] + roi_top = [0, 0, int(img_width * 0.74), sep_short_match.region[1]] crop_top = crop(img_item_descr, roi_top) concatenated_str = image_to_text(crop_top, do_pre_proc=do_pre_proc).text.lower().replace("\n", " ") for error, correction in Dataloader().error_map.items(): @@ -36,14 +32,14 @@ def read_item_type( ): item.item_type = ItemType.Material return item, concatenated_str - elif rarity in [ItemRarity.Common, ItemRarity.Legendary] and "elixir" not in concatenated_str: + elif item.rarity in [ItemRarity.Common, ItemRarity.Legendary] and "elixir" not in concatenated_str: # We check if it is a material mask, _ = color_filter(crop_top, COLORS.material_color, False) mean_val = np.mean(mask) if mean_val > 2.0: item.item_type = ItemType.Material return item, concatenated_str - if rarity == ItemRarity.Common: + if item.rarity == ItemRarity.Common: return item, concatenated_str if item.item_type == ItemType.Sigil: