diff --git a/analyzer.py b/analyzer.py index 771931a..5182f16 100644 --- a/analyzer.py +++ b/analyzer.py @@ -147,17 +147,6 @@ def load_suit_templates(): _suit_templates[s] = cv2.resize(img, (30, 30)) return _suit_templates -_rank_shape_templates = None -def load_rank_shape_templates(): - global _rank_shape_templates - if _rank_shape_templates is not None: return _rank_shape_templates - _rank_shape_templates = {} - for r in RANKS: - img = cv2.imread(f'{TEMPLATES_DIR}/rank_{r}.png', cv2.IMREAD_GRAYSCALE) - if img is not None: - _rank_shape_templates[r] = cv2.resize(img, (40, 50)) - print(f'[+] Loaded {len(_rank_shape_templates)} rank templates') - return _rank_shape_templates def detect_suit_by_shape(img_bgr): """Match suit symbol area against 4 templates from card files.""" @@ -175,21 +164,6 @@ def detect_suit_by_shape(img_bgr): best_score, best_suit = score, s return best_suit if best_score > 0.15 else '?' -def match_rank_by_shape(img_bgr, suit=None): - """Match rank — top 50% full width for better coverage of large digits.""" - tpls = load_rank_shape_templates() - if not tpls: return '?' - h, w = img_bgr.shape[:2] - rank_area = img_bgr[:int(h*0.50), :] # top half, full width - gray = cv2.cvtColor(rank_area, cv2.COLOR_BGR2GRAY) - _, binary = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) - binary_r = cv2.resize(binary, (40, 50)) - best_rank, best_score = '?', -1.0 - for r, tpl in tpls.items(): - score = float(cv2.matchTemplate(binary_r, tpl, cv2.TM_CCOEFF_NORMED).max()) - if score > best_score: - best_score, best_rank = score, r - return best_rank if best_score > 0.15 else '?' def detect_suit_ggpoker(img_bgr): """