Spaces:
Sleeping
Sleeping
mask arr
Browse files- identify_cards.py +5 -3
identify_cards.py
CHANGED
@@ -5,10 +5,12 @@ import os
|
|
5 |
import cv2
|
6 |
import numpy as np
|
7 |
from PIL import Image
|
8 |
-
# from transformers import pipeline
|
9 |
|
10 |
from utils import arrange_hand
|
11 |
|
|
|
|
|
|
|
12 |
# # --- グローバル変数としてTrOCRパイプラインを初期化 ---
|
13 |
# print("TrOCRのAIモデルを読み込んでいます...(初回は数分かかります)")
|
14 |
# try:
|
@@ -302,7 +304,7 @@ def get_not_white_mask(img):
|
|
302 |
l_channel = lab_patch[:, :, 0]
|
303 |
a_channel = lab_patch[:, :, 1]
|
304 |
b_channel = lab_patch[:, :, 2]
|
305 |
-
mask_l = cv2.threshold(l_channel,
|
306 |
mask_a = cv2.threshold(a_channel, 120, 255, cv2.THRESH_BINARY)[1]
|
307 |
mask_b = cv2.threshold(b_channel, 120, 255, cv2.THRESH_BINARY)[1]
|
308 |
mask_ab = cv2.bitwise_or(mask_a, mask_b)
|
@@ -509,7 +511,7 @@ def filter_thickness(
|
|
509 |
# print(" -> スートと判断し除外")
|
510 |
continue
|
511 |
# else:
|
512 |
-
|
513 |
|
514 |
if cropped_img.size > 0:
|
515 |
candidate["thickness"] = max_val
|
|
|
5 |
import cv2
|
6 |
import numpy as np
|
7 |
from PIL import Image
|
|
|
8 |
|
9 |
from utils import arrange_hand
|
10 |
|
11 |
+
# from transformers import pipeline
|
12 |
+
|
13 |
+
|
14 |
# # --- グローバル変数としてTrOCRパイプラインを初期化 ---
|
15 |
# print("TrOCRのAIモデルを読み込んでいます...(初回は数分かかります)")
|
16 |
# try:
|
|
|
304 |
l_channel = lab_patch[:, :, 0]
|
305 |
a_channel = lab_patch[:, :, 1]
|
306 |
b_channel = lab_patch[:, :, 2]
|
307 |
+
mask_l = cv2.threshold(l_channel, 160, 255, cv2.THRESH_BINARY_INV)[1]
|
308 |
mask_a = cv2.threshold(a_channel, 120, 255, cv2.THRESH_BINARY)[1]
|
309 |
mask_b = cv2.threshold(b_channel, 120, 255, cv2.THRESH_BINARY)[1]
|
310 |
mask_ab = cv2.bitwise_or(mask_a, mask_b)
|
|
|
511 |
# print(" -> スートと判断し除外")
|
512 |
continue
|
513 |
# else:
|
514 |
+
# print(" -> ランク候補として採用")
|
515 |
|
516 |
if cropped_img.size > 0:
|
517 |
candidate["thickness"] = max_val
|