Spaces:
Running
Running
preprocess
Browse files
main.py
CHANGED
@@ -25,6 +25,7 @@ from identify_cards import (
|
|
25 |
SUIT_TEMPLATE_PATH,
|
26 |
determine_and_correct_orientation,
|
27 |
find_rank_candidates,
|
|
|
28 |
get_suit_from_image_rules,
|
29 |
load_suit_templates,
|
30 |
save_img_with_rect,
|
@@ -213,14 +214,11 @@ async def analyze_image(image_paths: list[UploadFile]):
|
|
213 |
# img = Image.fromarray(
|
214 |
# cv2.cvtColor(candidate["img"], cv2.COLOR_BGR2RGB)
|
215 |
# )
|
216 |
-
|
217 |
-
|
218 |
-
)
|
219 |
-
|
220 |
# result = reader.readtext(candidate["img"])
|
221 |
-
result = reader.readtext(
|
222 |
-
candidate["img"], text_threshold=0.4
|
223 |
-
)
|
224 |
print(result)
|
225 |
if len(result) > 0:
|
226 |
ocr_results.append(result)
|
|
|
25 |
SUIT_TEMPLATE_PATH,
|
26 |
determine_and_correct_orientation,
|
27 |
find_rank_candidates,
|
28 |
+
get_not_white_mask,
|
29 |
get_suit_from_image_rules,
|
30 |
load_suit_templates,
|
31 |
save_img_with_rect,
|
|
|
214 |
# img = Image.fromarray(
|
215 |
# cv2.cvtColor(candidate["img"], cv2.COLOR_BGR2RGB)
|
216 |
# )
|
217 |
+
img = candidate["img"]
|
218 |
+
text_mask = get_not_white_mask(img)
|
219 |
+
masked_img = cv2.bitwise_and(img, img, mask=text)
|
|
|
220 |
# result = reader.readtext(candidate["img"])
|
221 |
+
result = reader.readtext(masked_img)
|
|
|
|
|
222 |
print(result)
|
223 |
if len(result) > 0:
|
224 |
ocr_results.append(result)
|