-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (22 loc) · 1005 Bytes
/
main.py
File metadata and controls
30 lines (22 loc) · 1005 Bytes
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
import argparse
import json
from pathlib import Path
from app.ocr_reader import read_player_image
def main():
parser = argparse.ArgumentParser(description="OCR simples para ler level e nome de jogador em imagem.")
parser.add_argument("--image", "-i", default="exemplos/player.png", help="Caminho da imagem")
parser.add_argument("--scale", type=int, default=4, help="Fator de aumento da imagem")
parser.add_argument("--threshold", type=int, default=145, help="Valor de threshold 0-255")
parser.add_argument("--debug", action="store_true", help="Salvar imagem preprocessada em saida/debug_preprocess.png")
args = parser.parse_args()
result = read_player_image(
args.image,
scale=args.scale,
threshold_value=args.threshold,
save_debug=args.debug,
)
print(json.dumps(result.to_dict(), ensure_ascii=False, indent=2))
if args.debug:
print("Debug salvo em: saida/debug_preprocess.png")
if __name__ == "__main__":
main()