- src/WeChatOcrCpp/ppv5.py +11 -5
src/WeChatOcrCpp/ppv5.py
CHANGED
|
@@ -15,12 +15,13 @@ conda create -n ppv5 python==3.10 pip \
|
|
| 15 |
|
| 16 |
"""
|
| 17 |
|
| 18 |
-
is_debug =
|
| 19 |
|
| 20 |
dic_cache = {}
|
| 21 |
|
| 22 |
from flask import Flask, request, jsonify
|
| 23 |
import threading
|
|
|
|
| 24 |
|
| 25 |
app = Flask(__name__)
|
| 26 |
|
|
@@ -88,6 +89,7 @@ ocr = PaddleOCR(
|
|
| 88 |
use_textline_orientation=False)
|
| 89 |
|
| 90 |
def ppresult_tojson(img, result):
|
|
|
|
| 91 |
|
| 92 |
jn = OrderedDict()
|
| 93 |
prism_wordsInfo = []
|
|
@@ -122,8 +124,10 @@ def ppresult_tojson(img, result):
|
|
| 122 |
j['charInfo'] = charInfo
|
| 123 |
|
| 124 |
img = cv2.rectangle(img, (lu['x'], lu['y']), (rd['x'], rd['y']), (255, 0, 0), 2)
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
| 127 |
for idx_word, (word, box) in enumerate(zip(words, boxs)):
|
| 128 |
|
| 129 |
if (len(word) == 1):
|
|
@@ -146,8 +150,10 @@ def ppresult_tojson(img, result):
|
|
| 146 |
|
| 147 |
# print(word)
|
| 148 |
img = cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) # 矩形的左上角, 矩形的右下角
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
| 151 |
|
| 152 |
# save_json('out.json', jn)
|
| 153 |
break # 只处理第一张图的结果
|
|
|
|
| 15 |
|
| 16 |
"""
|
| 17 |
|
| 18 |
+
is_debug = True
|
| 19 |
|
| 20 |
dic_cache = {}
|
| 21 |
|
| 22 |
from flask import Flask, request, jsonify
|
| 23 |
import threading
|
| 24 |
+
import platform
|
| 25 |
|
| 26 |
app = Flask(__name__)
|
| 27 |
|
|
|
|
| 89 |
use_textline_orientation=False)
|
| 90 |
|
| 91 |
def ppresult_tojson(img, result):
|
| 92 |
+
global is_debug
|
| 93 |
|
| 94 |
jn = OrderedDict()
|
| 95 |
prism_wordsInfo = []
|
|
|
|
| 124 |
j['charInfo'] = charInfo
|
| 125 |
|
| 126 |
img = cv2.rectangle(img, (lu['x'], lu['y']), (rd['x'], rd['y']), (255, 0, 0), 2)
|
| 127 |
+
if platform.system() == "Windows":
|
| 128 |
+
if is_debug:
|
| 129 |
+
cv2.imshow('orig', img)
|
| 130 |
+
cv2.waitKey(0)
|
| 131 |
for idx_word, (word, box) in enumerate(zip(words, boxs)):
|
| 132 |
|
| 133 |
if (len(word) == 1):
|
|
|
|
| 150 |
|
| 151 |
# print(word)
|
| 152 |
img = cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) # 矩形的左上角, 矩形的右下角
|
| 153 |
+
if platform.system() == "Windows":
|
| 154 |
+
if is_debug:
|
| 155 |
+
cv2.imshow('orgin', img)
|
| 156 |
+
cv2.waitKey(0)
|
| 157 |
|
| 158 |
# save_json('out.json', jn)
|
| 159 |
break # 只处理第一张图的结果
|