From 456bcc3ffcf79c0a49b7827afcab6b2782c55013 Mon Sep 17 00:00:00 2001 From: HinGwenWoong Date: Tue, 10 May 2022 19:30:52 +0800 Subject: [PATCH] Fix re-reco will clear all key message --- PPOCRLabel/PPOCRLabel.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 5c89e6f8..109d4c91 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -1149,7 +1149,10 @@ class MainWindow(QMainWindow): for box in self.result_dic: trans_dic = {"label": box[1][0], "points": box[0], "difficult": False} if self.kie_mode: - trans_dic.update({"key_cls": "None"}) + if len(box) == 3: + trans_dic.update({"key_cls": box[2]}) + else: + trans_dic.update({"key_cls": "None"}) if trans_dic["label"] == "" and mode == 'Auto': continue shapes.append(trans_dic) @@ -2047,6 +2050,7 @@ class MainWindow(QMainWindow): rec_flag = 0 for shape in self.canvas.shapes: box = [[int(p.x()), int(p.y())] for p in shape.points] + kie_cls = shape.key_cls if len(box) > 4: box = self.gen_quad_from_poly(np.array(box)) @@ -2062,17 +2066,27 @@ class MainWindow(QMainWindow): if shape.line_color == DEFAULT_LOCK_COLOR: shape.label = result[0][0] result.insert(0, box) + if self.kie_mode: + result.append(kie_cls) self.result_dic_locked.append(result) else: result.insert(0, box) + if self.kie_mode: + result.append(kie_cls) self.result_dic.append(result) else: print('Can not recognise the box') if shape.line_color == DEFAULT_LOCK_COLOR: shape.label = result[0][0] - self.result_dic_locked.append([box, (self.noLabelText, 0)]) + if self.kie_mode: + self.result_dic_locked.append([box, (self.noLabelText, 0), kie_cls]) + else: + self.result_dic_locked.append([box, (self.noLabelText, 0)]) else: - self.result_dic.append([box, (self.noLabelText, 0)]) + if self.kie_mode: + self.result_dic.append([box, (self.noLabelText, 0), kie_cls]) + else: + self.result_dic.append([box, (self.noLabelText, 0)]) try: if self.noLabelText == shape.label or result[1][0] == shape.label: print('label no change') -- GitLab