From ed193e07676c5525808d2c4e7a70e196c556b3b6 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:49:19 +0800 Subject: [PATCH] Fix: Invert planner page colors to have better ocr results on black letters and white background --- tasks/planner/scan.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tasks/planner/scan.py b/tasks/planner/scan.py index 353c51904..c0bfca11c 100644 --- a/tasks/planner/scan.py +++ b/tasks/planner/scan.py @@ -1,5 +1,6 @@ import re +import cv2 from pponnxcr.predict_system import BoxedResult from module.base.utils import area_center, area_in_area @@ -70,10 +71,7 @@ class OcrPlannerResult(OcrWhiteLetterOnComplexBackground, OcrItemName): return super().detect_and_ocr(image, *args, **kwargs) def pre_process(self, image): - # gray = rgb2gray(image) - # from PIL import Image - # Image.fromarray(gray).show() - # image = cv2.merge([gray, gray, gray]) + image = cv2.subtract((255, 255, 255, 0), image) return image