Quellcode durchsuchen

676table posthandler

chencheng vor 11 Monaten
Ursprung
Commit
27118df046
3 geänderte Dateien mit 6 neuen und 12 gelöschten Zeilen
  1. 0 4
      cores/check_table.py
  2. 4 1
      cores/post_decorators.py
  3. 2 7
      server.py

+ 0 - 4
cores/check_table.py

@@ -34,12 +34,9 @@ class Table:
         if self.html_arr != []:
             return
         tr_list = self.get_tr()
-        # print(tr_list)
-        # print('\n')
         for i in range(len(tr_list)):
             if tr_list[i] == '':
                 continue
-            # print(tr_list[i])
             tr = tr_list[i].split('</td>')[:-1]
             temp_list = []
             for cell in tr:
@@ -66,7 +63,6 @@ class Table:
         mask_green = cv2.inRange(hsv, lower_green, upper_green)
         color = [248, 248, 255]
         self.img[mask_green != 0] = color
-        cv2.imwrite('table.jpg', self.img)
 
     def get_str(self):
         str = ''

+ 4 - 1
cores/post_decorators.py

@@ -50,7 +50,8 @@ def rule3_decorator(f, *args, **kwargs):
     ['患直质', '1.6克', '3%', '']
     ['脂扇', '1.1', '19%', '']
     ['碳水化合物', '勿18.2克', '6%', '']
-
+    ['能量.', '408千焦',	'5%']
+    ['——精', '2.9克']
     '''
     predict_line = args[1]
     predict_line = f(*args, **kwargs)
@@ -58,6 +59,8 @@ def rule3_decorator(f, *args, **kwargs):
     predict_line = [re.sub('脂扇', '脂肪', s) for s in predict_line]
     predict_line = [re.sub('勿(.*克)', '\\1', s) for s in predict_line]
     predict_line = [re.sub('毫 克', '毫克', s) for s in predict_line]
+    predict_line = [re.sub('能量.', '能量', s) for s in predict_line]
+    predict_line = [re.sub('——精.', '——糖', s) for s in predict_line]
     return predict_line
 
 

+ 2 - 7
server.py

@@ -176,15 +176,10 @@ def table(image: TableInfo):
     img = base64_to_np(image.image)
     res, html = table_res(img)
     # print(html)
-    table=Table(html,img)
+    table = Table(html,img)
     if table.check_html():
         res, html = table_res(table.img)
-        # cv2.imwrite('table-out.jpg', table.img)
-    with open('./html_arr.txt', 'w') as f:
-        f.write(str(table.html_arr))
-    # print(table.html_arr)
-    # print(table.total)
-    # print(table.empty)
+
 
     if html:
         post_hander = PostHandler(html)