From c082b525b5e501dfa24038e3a85e444d88bfb1d0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 28 四月 2023 19:33:15 +0800
Subject: [PATCH] 开盘啦采集工具/看盘页面优化

---
 ocr_util.py |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ocr_util.py b/ocr_util.py
index 5038ecc..a0bbeda 100644
--- a/ocr_util.py
+++ b/ocr_util.py
@@ -16,19 +16,21 @@
 # 鏁板瓧璇嗗埆
 def recognize_code(img):
     results = num_reader.readtext(img, detail=0, mag_ratio=1.5)
-    print("璇嗗埆缁撴灉", results)
+    # print("璇嗗埆缁撴灉", results)
     if results:
-        result = results[0].strip()
-        code = result[-6:]
-        if code.isnumeric():
-            return code
+        for result in results:
+            result = result.strip()
+            if len(result) >= 6:
+                code = result[-6:]
+                if code.isnumeric():
+                    return code
     return None
 
 
 # 鏁板瓧璇嗗埆
 def recognize_num(img):
-    results = reader.readtext(img, detail=0, mag_ratio=2)
-    print("璇嗗埆缁撴灉", results)
+    results = num_reader.readtext(img, detail=0, mag_ratio=1.5)
+    # print("璇嗗埆缁撴灉", results)
     if results:
         result = results[0].strip()
         if result.isnumeric():
@@ -51,6 +53,9 @@
 
 
 if __name__ == '__main__':
-    start_time = time.time()
+    img = "C:\\Users\\Administrator\\Desktop\\ocr\\codes\\000021_23850.png"
+    results = num_reader.readtext(img, detail=1, mag_ratio=2)
+    print(results)
+
     # results = kpl_util.recognize_datas("C:\\Users\\Administrator\\Desktop\\test.png")
     # print(results)

--
Gitblit v1.8.0