fangjiasheng 1 рік тому
батько
коміт
1ef9982c91
1 змінених файлів з 12 додано та 6 видалено
  1. 12 6
      otr/table_line_pdf.py

+ 12 - 6
otr/table_line_pdf.py

@@ -2,6 +2,8 @@ import copy
 import math
 import random
 import time
+import traceback
+
 import numpy as np
 import cv2
 from matplotlib import pyplot as plt
@@ -348,10 +350,10 @@ def table_line_pdf(layout, page_no, show=0):
 
             # 筛选出线形矩形和非线形矩形
             if (element.height <= threshold) ^ (element.width <= threshold):
-                print('line_rect', element.stroke, element.stroking_color, element.non_stroking_color, element.fill, element.height * element.width, element.height, element.width)
+                # print('line_rect', element.stroke, element.stroking_color, element.non_stroking_color, element.fill, element.height * element.width, element.height, element.width)
                 line_rect_list.append(element)
             elif element.height > threshold and element.width > threshold:
-                print('non_line_rect', element.stroke, element.stroking_color, element.non_stroking_color, element.fill, element.height * element.width, element.height, element.width)
+                # print('non_line_rect', element.stroke, element.stroking_color, element.non_stroking_color, element.fill, element.height * element.width, element.height, element.width)
                 non_line_rect_list.append(element)
             else:
                 delete_lt_rect_list.append(element)
@@ -526,12 +528,16 @@ def table_line_pdf(layout, page_no, show=0):
         if lt_rect in delete_lt_rect_list:
             continue
         _b = lt_rect.bbox
-        if type(lt_rect.non_stroking_color) == tuple:
+        if type(lt_rect.non_stroking_color) in [tuple, list]:
             continue_flag = 0
             for t in lt_rect.non_stroking_color:
-                if float(t) >= threshold:
-                    continue_flag = 1
-                    break
+                try:
+                    if float(t) >= threshold:
+                        continue_flag = 1
+                        break
+                except:
+                    traceback.print_exc()
+                    continue
             if continue_flag:
                 continue
         elif lt_rect.non_stroking_color is not None and float(lt_rect.non_stroking_color) >= threshold: