From 6c4552450a15abbbd54272ade2d5b702acf177b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=A4=A7=E6=AF=9B?= <2443176192@qq.com> Date: Tue, 6 Jul 2021 16:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=96=87=E4=BB=B6=E5=A4=B9=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PPOCRLabel/PPOCRLabel.py | 27 ++++++++++++++++--- .../strings/strings-zh-CN.properties | 1 + .../resources/strings/strings.properties | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 9ffa909e..79c145d1 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -360,6 +360,9 @@ class MainWindow(QMainWindow, WindowMixin): opendir = action(getStr('openDir'), self.openDirDialog, 'Ctrl+u', 'open', getStr('openDir')) + open_dataset_dir = action(getStr('openDatasetDir'), self.openDatasetDirDialog, + 'Ctrl+p', 'open', getStr('openDatasetDir'), enabled=False) + save = action(getStr('save'), self.saveFile, 'Ctrl+V', 'verify', getStr('saveDetail'), enabled=False) @@ -519,9 +522,9 @@ class MainWindow(QMainWindow, WindowMixin): zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg, fitWindow=fitWindow, fitWidth=fitWidth, zoomActions=zoomActions, saveLabel=saveLabel, - undo=undo, undoLastPoint=undoLastPoint, + undo=undo, undoLastPoint=undoLastPoint,open_dataset_dir=open_dataset_dir, fileMenuActions=( - opendir, saveLabel, resetAll, quit), + opendir, open_dataset_dir, saveLabel, resetAll, quit), beginner=(), advanced=(), editMenu=(createpoly, edit, copy, delete,singleRere,None, undo, undoLastPoint, None, color1, self.drawSquaresOption), @@ -563,7 +566,7 @@ class MainWindow(QMainWindow, WindowMixin): self.autoSaveOption.triggered.connect(self.autoSaveFunc) addActions(self.menus.file, - (opendir, None, saveLabel, saveRec, self.autoSaveOption, None, resetAll, deleteImg, quit)) + (opendir, open_dataset_dir, None, saveLabel, saveRec, self.autoSaveOption, None, resetAll, deleteImg, quit)) addActions(self.menus.help, (showSteps, showInfo)) addActions(self.menus.view, ( @@ -1448,6 +1451,23 @@ class MainWindow(QMainWindow, WindowMixin): self.lastOpenDir = targetDirPath self.importDirImages(targetDirPath) + def openDatasetDirDialog(self, _value=False): #1458 + if not self.mayContinue(): + return + + if self.lastOpenDir and os.path.exists(self.lastOpenDir): + os.startfile(self.lastOpenDir) + defaultOpenDirPath = self.lastOpenDir + else: + if self.lang == 'ch': + self.actions.open_dataset_dir.setEnabled(False) + self.msgBox.warning(self, "提示", "\n 原文件夹已不存在,请从新选择数据集路径!") + defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.' + else: + self.actions.open_dataset_dir.setEnabled (False) + self.msgBox.warning (self, "Warn", "\n The original folder no longer exists, please choose the data set path again!") + defaultOpenDirPath = os.path.dirname (self.filePath) if self.filePath else '.' + def importDirImages(self, dirpath, isDelete = False): if not self.mayContinue() or not dirpath: return @@ -1495,6 +1515,7 @@ class MainWindow(QMainWindow, WindowMixin): self.reRecogButton.setEnabled(True) self.actions.AutoRec.setEnabled(True) self.actions.reRec.setEnabled(True) + self.actions.open_dataset_dir.setEnabled(True) def openPrevImg(self, _value=False): diff --git a/PPOCRLabel/resources/strings/strings-zh-CN.properties b/PPOCRLabel/resources/strings/strings-zh-CN.properties index 207f63d2..f246c8fe 100644 --- a/PPOCRLabel/resources/strings/strings-zh-CN.properties +++ b/PPOCRLabel/resources/strings/strings-zh-CN.properties @@ -31,6 +31,7 @@ save=确认 saveAs=另存为 fitWinDetail=缩放到当前窗口大小 openDir=打开目录 +openDatasetDir=打开数据集路径 copyPrevBounding=复制当前图像中的上一个边界框 showHide=显示/隐藏标签 changeSaveFormat=更改存储格式 diff --git a/PPOCRLabel/resources/strings/strings.properties b/PPOCRLabel/resources/strings/strings.properties index 321b1c65..55baea07 100644 --- a/PPOCRLabel/resources/strings/strings.properties +++ b/PPOCRLabel/resources/strings/strings.properties @@ -3,6 +3,7 @@ openFileDetail=Open image or label file quit=Quit quitApp=Quit application openDir=Open Dir +openDatasetDir=open DatasetDir copyPrevBounding=Copy previous Bounding Boxes in the current image changeSavedAnnotationDir=Change default saved Annotation dir openAnnotation=Open Annotation -- GitLab