Bladeren bron

修复isr识别流程

fangjiasheng 2 jaren geleden
bovenliggende
commit
142c895791
3 gewijzigde bestanden met toevoegingen van 12 en 7 verwijderingen
  1. 3 0
      format_convert/convert_image.py
  2. 8 6
      isr/isr_interface.py
  3. 1 1
      otr/otr_interface.py

+ 3 - 0
format_convert/convert_image.py

@@ -1,4 +1,5 @@
 # encoding=utf8
+import copy
 import inspect
 import io
 import logging
@@ -94,6 +95,7 @@ def image_process(image_np, image_path, is_from_pdf=False, is_from_docx=False, u
             else:
                 return g_r_i
         image_np = cv2.imread(image_path)
+        image_np_copy = copy.deepcopy(image_np)
         if image_np is None:
             return []
 
@@ -134,6 +136,7 @@ def image_process(image_np, image_path, is_from_pdf=False, is_from_docx=False, u
             # [1]代表检测不到印章,直接返回
             if isinstance(image_np, list) and image_np == [1]:
                 log("no seals detected!")
+                image_np = image_np_copy
             else:
                 isr_path = image_path.split(".")[0] + "_isr." + image_path.split(".")[-1]
                 cv2.imwrite(isr_path, image_np)

+ 8 - 6
isr/isr_interface.py

@@ -78,12 +78,14 @@ def detect_seal(image_np, model):
             try:
                 out_boxes, out_scores, out_classes = model.predict([image_resize, image_shape])
             except ValueError as e:
-                if '(0, 4)' in traceback.format_exc():
-                    log("there is no seal!")
-                    out_boxes, out_scores, out_classes = [], [], []
-                else:
-                    traceback.print_exc()
-                    raise e
+                # if '(0, 4)' in traceback.format_exc():
+                #     log("there is no seal!")
+                #     out_boxes, out_scores, out_classes = [], [], []
+                # else:
+                #     traceback.print_exc()
+                #     raise e
+                traceback.print_exc()
+                out_boxes, out_scores, out_classes = [], [], []
 
     if not isinstance(out_boxes, list) and not isinstance(out_classes, list):
         out_boxes = out_boxes.astype(np.int32)

+ 1 - 1
otr/otr_interface.py

@@ -40,7 +40,7 @@ from format_convert.utils import request_post, judge_error_code, get_intranet_ip
 from otr.table_line import get_points, get_split_line, get_points_row, \
     get_points_col, \
     delete_close_points, fix_outline, get_bbox, get_outline_point, delete_contain_bbox, points_to_line, \
-    fix_inner, merge_line, fix_corner, add_continue_bbox, delete_outline, table_net, table_line
+    fix_inner, merge_line, fix_corner, delete_outline, table_net, table_line
 from format_convert import _global
 
 # 接口配置