From 3f6c08b2ad9bbf2aef4f266d82badac27b4e3c2c Mon Sep 17 00:00:00 2001 From: 283375 Date: Fri, 10 Jan 2025 23:46:50 +0800 Subject: [PATCH] fix: preprocess_char_icon copyMakeBorder edge case --- src/arcaea_offline_ocr/device/ocr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcaea_offline_ocr/device/ocr.py b/src/arcaea_offline_ocr/device/ocr.py index 85f74ee..91d827e 100644 --- a/src/arcaea_offline_ocr/device/ocr.py +++ b/src/arcaea_offline_ocr/device/ocr.py @@ -110,7 +110,7 @@ class DeviceOcr: @staticmethod def preprocess_char_icon(img_gray: Mat): h, w = img_gray.shape[:2] - img = cv2.copyMakeBorder(img_gray, w - h, 0, 0, 0, cv2.BORDER_REPLICATE) + img = cv2.copyMakeBorder(img_gray, max(w - h, 0), 0, 0, 0, cv2.BORDER_REPLICATE) h, w = img.shape[:2] img = cv2.fillPoly( img,