-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (43 loc) · 1.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
from paddleocr import PaddleOCR
from prettytable import PrettyTable
directory = r".\images"
ocr = PaddleOCR(use_angle_cls=True, lang="en")
field_names = [""]
fields = [
"Max HP",
"ATK",
"DEF",
"Elemental Mastery",
"Crit Rate",
"Crit DMG",
"Healing Bonus",
"Incoming Healing Bonus",
"Energy Recharge",
"CD Reduction",
"Shield Strength",
"Pyro DMG Bonus",
]
for i, field in enumerate(fields):
fields[i] = [field]
for file_name in os.listdir(directory):
if file_name == ".gitkeep":
continue
field_names.append(file_name)
i = 0
img_path = os.path.join(directory, file_name)
result = ocr.ocr(img_path, cls=True)
for line in result:
print(line)
text = line[1][0]
if text.startswith("+"):
if not text.endswith("%"):
value = int(text[1:].replace(",", ""))
text = "+{:,}".format(value)
fields[i].append(text)
i += 1
table = PrettyTable()
table.field_names = field_names
table.add_rows(fields)
table.align = "l"
print(table)