Skip to content

Commit

Permalink
v0.1.1 Fixed missing spaces for character names
Browse files Browse the repository at this point in the history
  • Loading branch information
kel-z committed Jun 1, 2023
1 parent 0b7b647 commit ac1acc3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ HSR Scanner has the following scan options:
## Output
The output is loosely based off of Genshin's `.GOOD` export format. **Please note that the current output format is subject to change.**
### Notes
- Flat substats and percentage substats are differentiated by an underscore suffix in the key.
- Flat sub-stats and percentage sub-stats are differentiated by an underscore suffix in the key.
- Main stats will never have an underscore suffix.
- The `_id` value for light cones and relics is arbitrarily assigned during the scanning process. It is intended for easy lookup in case of any errors logged during the scan, for double-checking or manual correction purposes.
- For character traces, `ability_#` and `stat_#` are ordered by earliest availability (i.e. `stat_1` can be unlocked at Ascension 0, but `stat_2` requires Ascension 2).
Expand Down Expand Up @@ -171,4 +171,4 @@ Current output sample:
Check [sample_output.json](sample_output.json) for a full-sized, unfiltered example.

## Dev notes
- This app relies on reading text from images captured during the scan process, as opposed to reading directly from memory. As a result, OCR is prone to errors, especially given the variability of relic substats and lack of a model optimized for Star Rail. It also doesn't help that the inventory screen is translucent, as mentioned in step two of [instructions](#instructions). This issue can be alleviated via error-checking in future releases once every possible substat value is known and can be checked against.
- This app relies on reading text from images captured during the scan process, as opposed to reading directly from memory. As a result, OCR is prone to errors, especially given the variability of relic sub-stats and lack of a model optimized for Star Rail. It also doesn't help that the inventory screen is translucent, as mentioned in step two of [instructions](#instructions). This issue can be alleviated via error-checking in future releases once every possible sub-stat value is known and can be checked against.
16 changes: 8 additions & 8 deletions sample_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@
"level": 1,
"ascension": 0,
"superimposition": 1,
"location": "DanHeng",
"location": "Dan Heng",
"lock": true,
"_id": "light_cone_78"
},
Expand Down Expand Up @@ -977,7 +977,7 @@
"level": 50,
"ascension": 3,
"superimposition": 5,
"location": "March7th",
"location": "March 7th",
"lock": true,
"_id": "light_cone_111"
},
Expand Down Expand Up @@ -2472,7 +2472,7 @@
"value": 6.2
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_55"
},
Expand Down Expand Up @@ -2536,7 +2536,7 @@
"value": 2.7
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_52"
},
Expand Down Expand Up @@ -2608,7 +2608,7 @@
"value": 6.5
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_62"
},
Expand Down Expand Up @@ -2680,7 +2680,7 @@
"value": 3.1
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_58"
},
Expand Down Expand Up @@ -2744,7 +2744,7 @@
"value": 4.1
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_69"
},
Expand Down Expand Up @@ -4140,7 +4140,7 @@
"value": 2.5
}
],
"location": "March7th",
"location": "March 7th",
"lock": false,
"_id": "relic_135"
},
Expand Down
4 changes: 2 additions & 2 deletions src/relic_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def parse(self, stats_dict, interrupt, update_progress):
name, _ = get_closest_relic_name(name)
mainStatKey, _ = get_closest_relic_main_stat(mainStatKey)

# Parse substats
# Parse sub-stats
subStats = []
for i in range(1, 5):
key = stats_dict["subStatKey_" + str(i)]
Expand All @@ -142,7 +142,7 @@ def parse(self, stats_dict, interrupt, update_progress):
val = image_to_string(val_img, "0123456789.%", 7)
if not val:
# self._logger.emit(
# f"Relic ID {self._curr_id}: Found substat with no value: {key}. Either it doesn't exist or the OCR failed.")
# f"Relic ID {self._curr_id}: Found sub-stat with no value: {key}. Either it doesn't exist or the OCR failed.")
break

if val[-1] == '%':
Expand Down
4 changes: 2 additions & 2 deletions src/ui/hsr_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def setupUi(self, MainWindow):

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "HSR Scanner beta v0.1.0"))
MainWindow.setWindowTitle(_translate("MainWindow", "HSR Scanner beta v0.1.1"))
self.formGroupBox.setTitle(_translate("MainWindow", "Items to scan"))
self.checkBoxScanLightCones.setText(_translate("MainWindow", "Light Cones"))
self.checkBoxScanRelics.setText(_translate("MainWindow", "Relics"))
Expand Down Expand Up @@ -261,7 +261,7 @@ def retranslateUi(self, MainWindow):
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; font-weight:600; text-decoration: underline;\">HSR SCANNER v0.1.0</span></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; font-weight:600; text-decoration: underline;\">HSR SCANNER v0.1.1</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">- BETA -</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
Expand Down
4 changes: 2 additions & 2 deletions src/ui/hsr_scanner.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<bool>false</bool>
</property>
<property name="windowTitle">
<string>HSR Scanner beta v0.1.0</string>
<string>HSR Scanner beta v0.1.1</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="enabled">
Expand Down Expand Up @@ -497,7 +497,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600; text-decoration: underline;&quot;&gt;HSR SCANNER v0.1.0&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600; text-decoration: underline;&quot;&gt;HSR SCANNER v0.1.1&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;- BETA -&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
Expand Down
23 changes: 12 additions & 11 deletions src/utils/game_data_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,20 @@ def get_equipped_character(equipped_avatar_img, img_path_prefix):
max_conf = 0
character = ""

FILE_NAMES = [x.replace(" ", "") for x in CHARACTER_META_DATA.keys()]
if "TrailblazerDestruction" in FILE_NAMES:
FILE_NAMES.remove("TrailblazerDestruction")
FILE_NAMES.append("TrailblazerDestruction#M")
FILE_NAMES.append("TrailblazerDestruction#F")
if "TrailblazerPreservation" in FILE_NAMES:
FILE_NAMES.remove("TrailblazerPreservation")
FILE_NAMES.append("TrailblazerPreservation#M")
FILE_NAMES.append("TrailblazerPreservation#F")
CHARACTER_KEYS = list(CHARACTER_META_DATA.keys())
if "TrailblazerDestruction" in CHARACTER_KEYS:
CHARACTER_KEYS.remove("TrailblazerDestruction")
CHARACTER_KEYS.append("TrailblazerDestruction#M")
CHARACTER_KEYS.append("TrailblazerDestruction#F")
if "TrailblazerPreservation" in CHARACTER_KEYS:
CHARACTER_KEYS.remove("TrailblazerPreservation")
CHARACTER_KEYS.append("TrailblazerPreservation#M")
CHARACTER_KEYS.append("TrailblazerPreservation#F")

# Get highest confidence
for c in FILE_NAMES:
img = cv2.imread(f"{img_path_prefix}/{c}.png")
for c in CHARACTER_KEYS:
file_name = c.replace(" ", "")
img = cv2.imread(f"{img_path_prefix}/{file_name}.png")
img = cv2.cvtColor(img, cv2.COLOR_BGRA2RGB)
img = cv2.resize(img, (min_dim, min_dim))

Expand Down

0 comments on commit ac1acc3

Please sign in to comment.