dlxj commited on
Commit ·
892dac8
1
Parent(s): 9ee3a3d
预处理后的图片,坐标可能是这张图的坐标,而且还原不回去
Browse files
main.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# see huggingface/project/flask_auto_selection.py
|
| 3 |
|
| 4 |
# C:\Users\echod\.paddlex\official_models\PP-OCRv5_server_det
|
| 5 |
-
# c:\Users\echod\.conda\envs\ppv5\lib\site-packages\paddle\utils\cpp_extension\extension_utils.py 看
|
| 6 |
|
| 7 |
"""
|
| 8 |
|
|
@@ -102,6 +102,7 @@ def ppresult_tojson(img, result):
|
|
| 102 |
|
| 103 |
for res in result:
|
| 104 |
output_img = res['doc_preprocessor_res']['output_img'] # 这是预处理后的图片,坐标可能是这张图的坐标,而且还原不回去
|
|
|
|
| 105 |
jsn = res.json['res']
|
| 106 |
text_word = jsn['text_word']
|
| 107 |
text_word_boxes = jsn['text_word_boxes']
|
|
@@ -129,9 +130,9 @@ def ppresult_tojson(img, result):
|
|
| 129 |
|
| 130 |
img = cv2.rectangle(img, (lu['x'], lu['y']), (rd['x'], rd['y']), (255, 0, 0), 2)
|
| 131 |
if platform.system() == "Windows":
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
pass
|
| 136 |
for idx_word, (word, box) in enumerate(zip(words, boxs)):
|
| 137 |
|
|
@@ -156,9 +157,9 @@ def ppresult_tojson(img, result):
|
|
| 156 |
# print(word)
|
| 157 |
img = cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) # 矩形的左上角, 矩形的右下角
|
| 158 |
if platform.system() == "Windows":
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
pass
|
| 163 |
|
| 164 |
# save_json('out.json', jn)
|
|
@@ -209,7 +210,7 @@ def autoselection():
|
|
| 209 |
if __name__ == '__main__':
|
| 210 |
|
| 211 |
if is_debug:
|
| 212 |
-
pth_img = "data/
|
| 213 |
|
| 214 |
imgData = np.fromfile(pth_img, dtype=np.uint8)
|
| 215 |
img = cv2.imdecode(imgData, cv2.IMREAD_COLOR_BGR)
|
|
|
|
| 2 |
# see huggingface/project/flask_auto_selection.py
|
| 3 |
|
| 4 |
# C:\Users\echod\.paddlex\official_models\PP-OCRv5_server_det
|
| 5 |
+
# c:\Users\echod\.conda\envs\ppv5\lib\site-packages\paddle\utils\cpp_extension\extension_utils.py 看模型加载的代码在哪
|
| 6 |
|
| 7 |
"""
|
| 8 |
|
|
|
|
| 102 |
|
| 103 |
for res in result:
|
| 104 |
output_img = res['doc_preprocessor_res']['output_img'] # 这是预处理后的图片,坐标可能是这张图的坐标,而且还原不回去
|
| 105 |
+
# img = output_img
|
| 106 |
jsn = res.json['res']
|
| 107 |
text_word = jsn['text_word']
|
| 108 |
text_word_boxes = jsn['text_word_boxes']
|
|
|
|
| 130 |
|
| 131 |
img = cv2.rectangle(img, (lu['x'], lu['y']), (rd['x'], rd['y']), (255, 0, 0), 2)
|
| 132 |
if platform.system() == "Windows":
|
| 133 |
+
if is_debug:
|
| 134 |
+
cv2.imshow('orig', img)
|
| 135 |
+
cv2.waitKey(0)
|
| 136 |
pass
|
| 137 |
for idx_word, (word, box) in enumerate(zip(words, boxs)):
|
| 138 |
|
|
|
|
| 157 |
# print(word)
|
| 158 |
img = cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) # 矩形的左上角, 矩形的右下角
|
| 159 |
if platform.system() == "Windows":
|
| 160 |
+
if is_debug:
|
| 161 |
+
cv2.imshow('orgin', img)
|
| 162 |
+
cv2.waitKey(0)
|
| 163 |
pass
|
| 164 |
|
| 165 |
# save_json('out.json', jn)
|
|
|
|
| 210 |
if __name__ == '__main__':
|
| 211 |
|
| 212 |
if is_debug:
|
| 213 |
+
pth_img = "data/0025.jpg" # "data/第一单元.jpg"
|
| 214 |
|
| 215 |
imgData = np.fromfile(pth_img, dtype=np.uint8)
|
| 216 |
img = cv2.imdecode(imgData, cv2.IMREAD_COLOR_BGR)
|