Browse Source

solve the error of 676table

chencheng 1 year ago
parent
commit
efb7f4daff
2 changed files with 12 additions and 1 deletions
  1. 9 1
      cores/check_table.py
  2. 3 0
      cores/post_decorators.py

+ 9 - 1
cores/check_table.py

@@ -68,9 +68,17 @@ class Table:
         self.img[mask_green != 0] = color
         cv2.imwrite('table.jpg', self.img)
 
+    def get_str(self):
+        str = ''
+        for tr in self.html_arr:
+            for cell in tr:
+                str+=cell
+        return str
+
     def check_html(self):
         self.get_empty()
-        if self.empty > 4 and self.empty > self.total // 4:
+        html_str = self.get_str()
+        if (self.empty > 4 and self.empty > self.total // 4) or ('项目' in str and '每份' in str and '营养素参考值' in str and np.max([len(a) for a in self.html_arr])<3):
             self.change_green2white()
             return 1
         return 0

+ 3 - 0
cores/post_decorators.py

@@ -79,6 +79,9 @@ def rule4_decorator(f, *args, **kwargs):
 
 @decorator
 def rule5_decorator(f, *args, **kwargs):
+    '''
+        predict_line = ['项目 ', '每份(70g)营养素参考值%', '']
+    '''
     predict_line = args[1]
     predict_line = f(*args, **kwargs)
     try: