提交 c8e8bdbd 编写于 作者: R redearly123/PaddleOCR

add feature lock/unlock selected shapes

上级 ee060d07
...@@ -1117,9 +1117,8 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1117,9 +1117,8 @@ class MainWindow(QMainWindow, WindowMixin):
difficult=s.difficult) # bool difficult=s.difficult) # bool
shapes = [] if mode == 'Auto' else \ shapes = [] if mode == 'Auto' else \
[format_shape(shape) for shape in self.canvas.shapes] [format_shape(shape) for shape in self.canvas.shapes if shape.line_color != DEFAULT_LOCK_COLOR]
# Can add differrent annotation formats here # Can add differrent annotation formats here
print("in save labels self.result_dic",self.result_dic)
for box in self.result_dic : for box in self.result_dic :
trans_dic = {"label": box[1][0], "points": box[0], 'difficult': False} trans_dic = {"label": box[1][0], "points": box[0], 'difficult': False}
if trans_dic["label"] == "" and mode == 'Auto': if trans_dic["label"] == "" and mode == 'Auto':
...@@ -1131,7 +1130,6 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1131,7 +1130,6 @@ class MainWindow(QMainWindow, WindowMixin):
for box in shapes: for box in shapes:
trans_dic.append({"transcription": box['label'], "points": box['points'], 'difficult': box['difficult']}) trans_dic.append({"transcription": box['label'], "points": box['points'], 'difficult': box['difficult']})
self.PPlabel[annotationFilePath] = trans_dic self.PPlabel[annotationFilePath] = trans_dic
if mode == 'Auto': if mode == 'Auto':
self.Cachelabel[annotationFilePath] = trans_dic self.Cachelabel[annotationFilePath] = trans_dic
...@@ -1375,6 +1373,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1375,6 +1373,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.actions.save.setEnabled(True) self.actions.save.setEnabled(True)
if len(self.canvas.lockedShapes) != 0: if len(self.canvas.lockedShapes) != 0:
self.actions.save.setEnabled(True) self.actions.save.setEnabled(True)
self.setDirty()
self.canvas.setEnabled(True) self.canvas.setEnabled(True)
self.adjustScale(initial=True) self.adjustScale(initial=True)
self.paintCanvas() self.paintCanvas()
...@@ -1688,16 +1687,15 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1688,16 +1687,15 @@ class MainWindow(QMainWindow, WindowMixin):
self.saveLockedShapes() self.saveLockedShapes()
if mode == 'Manual': if mode == 'Manual':
if len(self.result_dic_locked) == 0: self.result_dic_locked = []
img = cv2.imread(self.filePath) img = cv2.imread(self.filePath)
width, height = self.image.width(), self.image.height() width, height = self.image.width(), self.image.height()
for shape in self.canvas.lockedShapes: for shape in self.canvas.lockedShapes:
print(shape) box = [[int(p[0]*width), int(p[1]*height)] for p in shape['ratio']]
box = [[int(p[0]*width), int(p[1]*height)] for p in shape['ratio']] assert len(box) == 4
assert len(box) == 4 result = [(shape['transcription'],1)]
result = [(shape['transcription'],1)] result.insert(0, box)
result.insert(0, box) self.result_dic_locked.append(result)
self.result_dic_locked.append(result)
self.result_dic += self.result_dic_locked self.result_dic += self.result_dic_locked
self.result_dic_locked = [] self.result_dic_locked = []
if annotationFilePath and self.saveLabels(annotationFilePath, mode=mode): if annotationFilePath and self.saveLabels(annotationFilePath, mode=mode):
...@@ -1957,8 +1955,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1957,8 +1955,7 @@ class MainWindow(QMainWindow, WindowMixin):
else: else:
rec_flag += 1 rec_flag += 1
except IndexError as e: except IndexError as e:
print('except:', e) print('Can not recognise the box')
if (len(self.result_dic) > 0 and rec_flag > 0)or self.canvas.lockedShapes: if (len(self.result_dic) > 0 and rec_flag > 0)or self.canvas.lockedShapes:
self.canvas.isInTheSameImage = True self.canvas.isInTheSameImage = True
self.saveFile(mode='Auto') self.saveFile(mode='Auto')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册