✨ feat: workable
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import sys
|
||||
import cv2
|
||||
from hbc.config import GridConfig, TemplateMatchConfig
|
||||
from hbc.templates import TemplateLibrary
|
||||
from hbc.recognizer import recognize_board
|
||||
|
||||
image_path = sys.argv[1]
|
||||
level = int(sys.argv[2])
|
||||
img = cv2.imread(image_path)
|
||||
grid = GridConfig.load_json(f"layouts/level{level}.json")
|
||||
lib = TemplateLibrary.load(TemplateMatchConfig(templates_dir="templates"))
|
||||
board = recognize_board(img, grid, lib)
|
||||
for r in range(board.rows):
|
||||
row = []
|
||||
for c in range(board.cols):
|
||||
cell = board.get(r, c)
|
||||
if cell.is_brick:
|
||||
lab = "ICE"
|
||||
elif cell.is_empty:
|
||||
lab = "."
|
||||
else:
|
||||
lab = cell.meta.get("label", "?")
|
||||
row.append(f"{lab[:6]:>6}:{cell.meta.get('score', '-')}")
|
||||
print(" ".join(row))
|
||||
Reference in New Issue
Block a user