Skip to content

Commit

Permalink
robusitfy inherent detection
Browse files Browse the repository at this point in the history
  • Loading branch information
aeon0 committed Jan 28, 2024
1 parent 4e6502a commit ee23ca9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/item/descr/find_affixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def split_into_paragraphs(
else:
current_paragraph += f" {text}"

if current_paragraph:
# Filter special errors were affix seems to wrongly detect sth like "% :" on a seperate line
# TODO: Is this nice? Not sure
if current_paragraph and len(current_paragraph) > 3:
paragraphs.append(current_paragraph.strip())

return paragraphs
Expand Down Expand Up @@ -68,11 +70,11 @@ def find_affixes(
# Affix starts at first bullet point
img_width = img_item_descr.shape[1]
line_height = Config().ui_offsets["item_descr_line_height"]
affix_top_left = [affix_bullets[0].center[0] + line_height // 4, affix_bullets[0].center[1] - int(line_height * 0.7)]
affix_top_left = [affix_bullets[0].center[0] + int(line_height * 0.3), affix_bullets[0].center[1] - int(line_height * 0.6)]

# Calc full region of all affixes
affix_width = img_width - affix_top_left[0]
affix_height = bottom_limit - affix_top_left[1] - int(line_height * 0.4)
affix_height = bottom_limit - affix_top_left[1] - int(line_height * 0.75)
full_affix_region = [*affix_top_left, affix_width, affix_height]
crop_full_affix = crop(img_item_descr, full_affix_region)
# cv2.imwrite("crop_full_affix.png", crop_full_affix)
Expand Down
Binary file added test/assets/item/read_descr_rare_1080p_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions test/item/read_descr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,24 @@
],
),
),
(
(1920, 1080),
f"{BASE_PATH}/read_descr_rare_1080p_5.png",
Item(
ItemRarity.Rare,
ItemType.Mace2H,
628,
None,
[
Affix("critical_strike_damage", 29.0),
Affix("core_skill_damage", 28),
Affix("ultimate_skill_damage", 29),
],
[
Affix("overpower_damage", 75),
],
),
),
],
)
def test_read_descr(img_res: tuple[int, int], input_img: str, expected_item: Item):
Expand Down

0 comments on commit ee23ca9

Please sign in to comment.