Skip to content

Commit

Permalink
Merge pull request #90 from kel-z/dev
Browse files Browse the repository at this point in the history
Release v1.1.0: partial relic scan, trailblazer item fix, trace level fail fallback
  • Loading branch information
kel-z committed Jun 4, 2024
2 parents 87c879b + d56c2d0 commit 4f2feca
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 89 deletions.
2 changes: 2 additions & 0 deletions src/config/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"superimposition": (0.53, 0.495, 0.6, 0.55),
"equipped": (0.45, 0.935, 0.67, 0.965),
"equipped_avatar": (0.3505, 0.916, 0.4375, 0.966675),
"equipped_avatar_trailblazer": (0.3905, 0.916, 0.4775, 0.966675),
"lock": (0.896, 0.321, 0.97, 0.365),
},
"relic": {
Expand All @@ -82,6 +83,7 @@
"rarity": (0.07, 0.15, 0.2, 0.22),
"equipped": (0.45, 0.935, 0.67, 0.965),
"equipped_avatar": (0.3505, 0.916, 0.4375, 0.966675),
"equipped_avatar_trailblazer": (0.3905, 0.916, 0.4775, 0.966675),
"mainStatKey": (0.11, 0.358, 0.7, 0.4),
"substat_names": (0.11, 0.4, 0.5, 0.6),
"substat_vals": (0.775, 0.4, 0.975, 0.6),
Expand Down
9 changes: 0 additions & 9 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import asyncio
import datetime
import os
import sys
import traceback
import winsound

import pytesseract
from pynput.keyboard import Key, Listener
from PyQt6 import QtGui, QtWidgets
from PyQt6.QtCore import QSettings, QThread, QUrl, pyqtSignal
Expand All @@ -26,10 +24,6 @@
)
from utils.window import bring_window_to_foreground, flash_window

# set environment variables for Tesseract
os.environ["TESSDATA_PREFIX"] = resource_path("assets/tesseract/tessdata")
pytesseract.pytesseract.tesseract_cmd = resource_path("assets/tesseract/tesseract.exe")


class HSRScannerUI(QtWidgets.QMainWindow, Ui_MainWindow):
"""HSRScannerUI handles the UI for the HSR Scanner application"""
Expand Down Expand Up @@ -115,9 +109,6 @@ def setup_ui(self, MainWindow: QtWidgets.QMainWindow) -> None:
self.pushButtonOpenLocation.clicked.connect(self.open_output_location)
self.pushButtonRestoreDefaults.clicked.connect(self.reset_settings)

# delete the Advanced tab for now
self.tabWidget.removeTab(1)

self.load_settings()

def change_output_location(self) -> None:
Expand Down
25 changes: 24 additions & 1 deletion src/services/scanner/parsers/character_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,33 @@ def parse(self, stats_dict: dict) -> dict:
for k, v in traces_dict["levels"].items():
try:
res = image_to_string(v, "0123456789/", 6, True, preprocess_trace_img)
if not res or not res.find("/"):

# If the first OCR attempt failed, try again with different parameters
if not res or "/" not in res:
self._log(
f"{character['key']}: Failed to parse '{k}' level. Trying again with PSM 6 and no force preprocess.",
LogLevel.DEBUG,
)
res = image_to_string(
v, "0123456789/", 6, False, preprocess_trace_img
)
if not res or "/" not in res:
self._log(
f"{character['key']}: Failed to parse '{k}' level. Trying again with PSM 7 and force preprocess.",
LogLevel.DEBUG,
)
res = image_to_string(
v, "0123456789/", 7, True, preprocess_trace_img
)
if not res or "/" not in res:
self._log(
f"{character['key']}: Failed to parse '{k}' level. Trying again with PSM 7 and no force preprocess.",
LogLevel.DEBUG,
)
res = image_to_string(
v, "0123456789/", 7, False, preprocess_trace_img
)

character["skills"][k] += int(res.split("/")[0])
if not 1 <= character["skills"][k] <= (6 if k == "basic" else 10):
raise ValueError
Expand Down
3 changes: 3 additions & 0 deletions src/services/scanner/parsers/light_cone_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def parse(self, stats_dict: dict, lc_id: int) -> dict:
if equipped == "Equipped":
equipped_avatar = stats_dict["equipped_avatar"]
location = self._game_data.get_equipped_character(equipped_avatar)
elif equipped == "Equippe": # https://github.com/kel-z/HSR-Scanner/issues/88
equipped_avatar = stats_dict["equipped_avatar_trailblazer"]
location = self._game_data.get_equipped_character(equipped_avatar)

result = {
"key": name,
Expand Down
3 changes: 3 additions & 0 deletions src/services/scanner/parsers/relic_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def parse(self, stats_dict: dict, relic_id: int) -> dict:
if equipped == "Equipped":
equipped_avatar = stats_dict["equipped_avatar"]
location = self._game_data.get_equipped_character(equipped_avatar)
elif equipped == "Equippe": # https://github.com/kel-z/HSR-Scanner/issues/88
equipped_avatar = stats_dict["equipped_avatar_trailblazer"]
location = self._game_data.get_equipped_character(equipped_avatar)

result = {
"set": set_key,
Expand Down
2 changes: 1 addition & 1 deletion src/services/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async def start_scan(self) -> dict:

return {
"source": "HSR-Scanner",
"build": "v1.0.0",
"build": "v1.1.0",
"version": 3,
"metadata": {
"uid": int(uid) if uid else None,
Expand Down
Loading

0 comments on commit 4f2feca

Please sign in to comment.