From d52d5458640eee94b5c3878c514d3dc270642309 Mon Sep 17 00:00:00 2001 From: 283375 Date: Sat, 7 Oct 2023 13:16:32 +0800 Subject: [PATCH] fix: max recall ocr improve --- src/arcaea_offline_ocr/device/v2/ocr.py | 6 +++--- src/arcaea_offline_ocr/mask.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arcaea_offline_ocr/device/v2/ocr.py b/src/arcaea_offline_ocr/device/v2/ocr.py index bff9c6b..1dab23d 100644 --- a/src/arcaea_offline_ocr/device/v2/ocr.py +++ b/src/arcaea_offline_ocr/device/v2/ocr.py @@ -146,9 +146,9 @@ class DeviceV2Ocr: contours, _ = cv2.findContours( roi_closed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE ) - rects = sorted( - [cv2.boundingRect(c) for c in contours], key=lambda r: r[0], reverse=True - ) + rects = [cv2.boundingRect(c) for c in contours] + rects = [r for r in rects if r[2] > 5 and r[3] > 5] + rects = sorted(rects, key=lambda r: r[0], reverse=True) max_recall_roi = crop_xywh(roi, rects[0]) return ocr_digits_by_contour_knn(max_recall_roi, self.knn_model) diff --git a/src/arcaea_offline_ocr/mask.py b/src/arcaea_offline_ocr/mask.py index 085c99d..29e8560 100644 --- a/src/arcaea_offline_ocr/mask.py +++ b/src/arcaea_offline_ocr/mask.py @@ -56,7 +56,7 @@ BYD_MIN_HSV = np.array([170, 50, 50], np.uint8) BYD_MAX_HSV = np.array([179, 210, 198], np.uint8) MAX_RECALL_PURPLE_MIN_HSV = np.array([125, 0, 0], np.uint8) -MAX_RECALL_PURPLE_MAX_HSV = np.array([130, 100, 150], np.uint8) +MAX_RECALL_PURPLE_MAX_HSV = np.array([145, 100, 150], np.uint8) def mask_gray(__img_bgr: Mat):