From 76b610aa6d41b69eb10caaf419b148a53831989f Mon Sep 17 00:00:00 2001 From: tzutalin Date: Sat, 21 Nov 2015 17:39:40 +0800 Subject: [PATCH] Support openPrevious function --- README.md | 16 +++++++++++++++- labelImg.py | 31 +++++++++++++++++++++++++------ resources.qrc | 1 + 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6cd3b721..ca7dd9fe 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ In order to build the resource and assets, you need to install pyqt4-dev-tools: `$ sudo apt-get install pyqt4-dev-tools` ## Usage -After cloning the code, you should run `make` to generate the resource file. +After cloning the code, you should run `make all` to generate the resource file. You can then start annotating by running `./labelImg.py`. For usage instructions you can see [Here](https://youtu.be/p0nR2YsCY_U) @@ -30,6 +30,18 @@ You can also see [ImageNet Utils](https://github.com/tzutalin/ImageNet_Utils) to You can edit the [data/predefined_classes.txt](https://github.com/tzutalin/labelImg/blob/master/data/predefined_classes.txt) to load pre-defined classes +### General steps from scratch + +* Build and launch. `make all; python labelImg.py` + +* Click 'Change default saved annotation folder' in Menu/File + +* Click 'Open Dir' + +* Click 'Create RectBox' + +The annotation will be saved to the folder you specifiy + ### Hotkeys * Ctrl + r : Change the defult target dir which saving annotation files @@ -39,3 +51,5 @@ You can edit the [data/predefined_classes.txt](https://github.com/tzutalin/label * Ctrl + s : Save * n : Next image + +* p : Previou image diff --git a/labelImg.py b/labelImg.py index 621d4be7..a2d607e8 100755 --- a/labelImg.py +++ b/labelImg.py @@ -142,6 +142,9 @@ class MainWindow(QMainWindow, WindowMixin): openNextImg = action('&Next Image', self.openNextImg, 'n', 'next', u'Open Next') + openPrevImg = action('&Prev Image', self.openPrevImg, + 'p', 'prev', u'Open Prev') + save = action('&Save', self.saveFile, 'Ctrl+S', 'save', u'Save labels to file', enabled=False) saveAs = action('&Save As', self.saveFileAs, @@ -278,7 +281,7 @@ class MainWindow(QMainWindow, WindowMixin): self.tools = self.toolbar('Tools') self.actions.beginner = ( - open, opendir, openNextImg, save, None, create, copy, delete, None, + open, opendir, openNextImg, openPrevImg, save, None, create, copy, delete, None, zoomIn, zoom, zoomOut, fitWindow, fitWidth) self.actions.advanced = ( @@ -347,10 +350,6 @@ class MainWindow(QMainWindow, WindowMixin): self.populateModeActions() - #self.firstStart = True - #if self.firstStart: - # QWhatsThis.enterWhatsThisMode() - ## Support Functions ## def noShapes(self): @@ -822,6 +821,19 @@ class MainWindow(QMainWindow, WindowMixin): if not self.mayContinue(): return + if len(self.mImgList) <= 0: + return + + if self.filename is None: + return + + currIndex = self.mImgList.index(self.filename) + if currIndex -1 >= 0: + filename = self.mImgList[currIndex-1] + + if filename: + self.loadFile(filename) + def openNextImg(self, _value=False): # Proceding next image without dialog if having any label @@ -834,7 +846,14 @@ class MainWindow(QMainWindow, WindowMixin): if len(self.mImgList) <= 0: return - filename = self.mImgList.pop(0) + + if self.filename is None: + filename = self.mImgList[0] + else: + currIndex = self.mImgList.index(self.filename) + if currIndex + 1 < len(self.mImgList): + filename = self.mImgList[currIndex+1] + if filename: self.loadFile(filename) diff --git a/resources.qrc b/resources.qrc index 8875f58e..9ae18234 100644 --- a/resources.qrc +++ b/resources.qrc @@ -26,6 +26,7 @@ icons/zoom-out.png icons/cancel.png icons/next.png +icons/prev.png