提交 547feabe 编写于 作者: qq_25193841's avatar qq_25193841

Merge remote-tracking branch 'origin/dygraph' into dygraph

...@@ -27,7 +27,12 @@ import json ...@@ -27,7 +27,12 @@ import json
import cv2 import cv2
__dir__ = os.path.dirname(os.path.abspath(__file__)) __dir__ = os.path.dirname(os.path.abspath(__file__))
import numpy as np
sys.path.append(__dir__) sys.path.append(__dir__)
sys.path.append(os.path.abspath(os.path.join(__dir__, '../..'))) sys.path.append(os.path.abspath(os.path.join(__dir__, '../..')))
sys.path.append("..") sys.path.append("..")
...@@ -78,7 +83,7 @@ class WindowMixin(object): ...@@ -78,7 +83,7 @@ class WindowMixin(object):
addActions(menu, actions) addActions(menu, actions)
return menu return menu
def toolbar(self, title, actions=None): def toolbar(self, title, actions=None):
toolbar = ToolBar(title) toolbar = ToolBar(title)
toolbar.setObjectName(u'%sToolBar' % title) toolbar.setObjectName(u'%sToolBar' % title)
# toolbar.setOrientation(Qt.Vertical) # toolbar.setOrientation(Qt.Vertical)
...@@ -98,7 +103,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -98,7 +103,7 @@ class MainWindow(QMainWindow, WindowMixin):
# Load setting in the main thread # Load setting in the main thread
self.settings = Settings() self.settings = Settings()
self.settings.load() self.settings.load()
settings = self.settings settings = self.settings
self.lang = lang self.lang = lang
# Load string bundle for i18n # Load string bundle for i18n
...@@ -159,7 +164,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -159,7 +164,7 @@ class MainWindow(QMainWindow, WindowMixin):
filelistLayout = QVBoxLayout() filelistLayout = QVBoxLayout()
filelistLayout.setContentsMargins(0, 0, 0, 0) filelistLayout.setContentsMargins(0, 0, 0, 0)
filelistLayout.addWidget(self.fileListWidget) filelistLayout.addWidget(self.fileListWidget)
self.AutoRecognition = QToolButton() self.AutoRecognition = QToolButton()
self.AutoRecognition.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.AutoRecognition.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.AutoRecognition.setIcon(newIcon('Auto')) self.AutoRecognition.setIcon(newIcon('Auto'))
...@@ -176,7 +181,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -176,7 +181,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.filedock.setObjectName(getStr('files')) self.filedock.setObjectName(getStr('files'))
self.filedock.setWidget(fileListContainer) self.filedock.setWidget(fileListContainer)
self.addDockWidget(Qt.LeftDockWidgetArea, self.filedock) self.addDockWidget(Qt.LeftDockWidgetArea, self.filedock)
######## Right area ########## ######## Right area ##########
listLayout = QVBoxLayout() listLayout = QVBoxLayout()
listLayout.setContentsMargins(0, 0, 0, 0) listLayout.setContentsMargins(0, 0, 0, 0)
...@@ -250,7 +255,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -250,7 +255,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.imgsplider.setMaximum(150) self.imgsplider.setMaximum(150)
self.imgsplider.setSingleStep(1) self.imgsplider.setSingleStep(1)
self.imgsplider.setTickPosition(QSlider.TicksBelow) self.imgsplider.setTickPosition(QSlider.TicksBelow)
self.imgsplider.setTickInterval(1) self.imgsplider.setTickInterval(1)
op = QGraphicsOpacityEffect() op = QGraphicsOpacityEffect()
op.setOpacity(0.2) op.setOpacity(0.2)
self.imgsplider.setGraphicsEffect(op) self.imgsplider.setGraphicsEffect(op)
...@@ -266,7 +271,9 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -266,7 +271,9 @@ class MainWindow(QMainWindow, WindowMixin):
self.zoomWidget = ZoomWidget() self.zoomWidget = ZoomWidget()
self.colorDialog = ColorDialog(parent=self) self.colorDialog = ColorDialog(parent=self)
self.zoomWidgetValue = self.zoomWidget.value() self.zoomWidgetValue = self.zoomWidget.value()
self.msgBox = QMessageBox()
########## thumbnail ######### ########## thumbnail #########
hlayout = QHBoxLayout() hlayout = QHBoxLayout()
m = (0, 0, 0, 0) m = (0, 0, 0, 0)
...@@ -294,7 +301,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -294,7 +301,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.nextButton.setStyleSheet('border: none;') self.nextButton.setStyleSheet('border: none;')
self.nextButton.clicked.connect(self.openNextImg) self.nextButton.clicked.connect(self.openNextImg)
self.nextButton.setShortcut('d') self.nextButton.setShortcut('d')
hlayout.addWidget(self.preButton) hlayout.addWidget(self.preButton)
hlayout.addWidget(self.iconlist) hlayout.addWidget(self.iconlist)
hlayout.addWidget(self.nextButton) hlayout.addWidget(self.nextButton)
...@@ -303,7 +310,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -303,7 +310,7 @@ class MainWindow(QMainWindow, WindowMixin):
iconListContainer = QWidget() iconListContainer = QWidget()
iconListContainer.setLayout(hlayout) iconListContainer.setLayout(hlayout)
iconListContainer.setFixedHeight(100) iconListContainer.setFixedHeight(100)
########### Canvas ########### ########### Canvas ###########
self.canvas = Canvas(parent=self) self.canvas = Canvas(parent=self)
self.canvas.zoomRequest.connect(self.zoomRequest) self.canvas.zoomRequest.connect(self.zoomRequest)
...@@ -360,6 +367,9 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -360,6 +367,9 @@ class MainWindow(QMainWindow, WindowMixin):
opendir = action(getStr('openDir'), self.openDirDialog, opendir = action(getStr('openDir'), self.openDirDialog,
'Ctrl+u', 'open', getStr('openDir')) '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, save = action(getStr('save'), self.saveFile,
'Ctrl+V', 'verify', getStr('saveDetail'), enabled=False) 'Ctrl+V', 'verify', getStr('saveDetail'), enabled=False)
...@@ -439,7 +449,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -439,7 +449,7 @@ class MainWindow(QMainWindow, WindowMixin):
AutoRec = action(getStr('autoRecognition'), self.autoRecognition, AutoRec = action(getStr('autoRecognition'), self.autoRecognition,
'', 'Auto', getStr('autoRecognition'), enabled=False) '', 'Auto', getStr('autoRecognition'), enabled=False)
reRec = action(getStr('reRecognition'), self.reRecognition, reRec = action(getStr('reRecognition'), self.reRecognition,
'Ctrl+Shift+R', 'reRec', getStr('reRecognition'), enabled=False) 'Ctrl+Shift+R', 'reRec', getStr('reRecognition'), enabled=False)
singleRere = action(getStr('singleRe'), self.singleRerecognition, singleRere = action(getStr('singleRe'), self.singleRerecognition,
...@@ -457,6 +467,12 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -457,6 +467,12 @@ class MainWindow(QMainWindow, WindowMixin):
undoLastPoint = action(getStr("undoLastPoint"), self.canvas.undoLastPoint, undoLastPoint = action(getStr("undoLastPoint"), self.canvas.undoLastPoint,
'Ctrl+Z', "undo", getStr("undoLastPoint"), enabled=False) 'Ctrl+Z', "undo", getStr("undoLastPoint"), enabled=False)
rotateLeft = action(getStr("rotateLeft"), self.rotateLeftImg,
'Ctrl+Alt+L', "rotateLeft", getStr("rotateLeft"), enabled=False)
rotateRight = action(getStr("rotateRight"), self.rotateRightImg,
'Ctrl+Alt+R', "rotateRight", getStr("rotateRight"), enabled=False)
undo = action(getStr("undo"), self.undoShapeEdit, undo = action(getStr("undo"), self.undoShapeEdit,
'Ctrl+Z', "undo", getStr("undo"), enabled=False) 'Ctrl+Z', "undo", getStr("undo"), enabled=False)
...@@ -520,13 +536,14 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -520,13 +536,14 @@ class MainWindow(QMainWindow, WindowMixin):
zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg, zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg,
fitWindow=fitWindow, fitWidth=fitWidth, fitWindow=fitWindow, fitWidth=fitWidth,
zoomActions=zoomActions, saveLabel=saveLabel, zoomActions=zoomActions, saveLabel=saveLabel,
undo=undo, undoLastPoint=undoLastPoint, undo=undo, undoLastPoint=undoLastPoint,open_dataset_dir=open_dataset_dir,
rotateLeft=rotateLeft,rotateRight=rotateRight,
fileMenuActions=( fileMenuActions=(
opendir, saveLabel, resetAll, quit), opendir, open_dataset_dir, saveLabel, resetAll, quit),
beginner=(), advanced=(), beginner=(), advanced=(),
editMenu=(createpoly, edit, copy, delete,singleRere,None, undo, undoLastPoint, editMenu=(createpoly, edit, copy, delete,singleRere,None, undo, undoLastPoint,
None, color1, self.drawSquaresOption), None, rotateLeft, rotateRight, None, color1, self.drawSquaresOption),
beginnerContext=(create, edit, copy, delete, singleRere), beginnerContext=(create, edit, copy, delete, singleRere, rotateLeft, rotateRight,),
advancedContext=(createMode, editMode, edit, copy, advancedContext=(createMode, editMode, edit, copy,
delete, shapeLineColor, shapeFillColor), delete, shapeLineColor, shapeFillColor),
onLoadActive=( onLoadActive=(
...@@ -564,7 +581,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -564,7 +581,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.autoSaveOption.triggered.connect(self.autoSaveFunc) self.autoSaveOption.triggered.connect(self.autoSaveFunc)
addActions(self.menus.file, 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, (showKeys,showSteps, showInfo)) addActions(self.menus.help, (showKeys,showSteps, showInfo))
addActions(self.menus.view, ( addActions(self.menus.view, (
...@@ -778,6 +795,48 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -778,6 +795,48 @@ class MainWindow(QMainWindow, WindowMixin):
self.actions.create.setEnabled(False) self.actions.create.setEnabled(False)
self.actions.undoLastPoint.setEnabled(True) self.actions.undoLastPoint.setEnabled(True)
def rotateImg(self, filename, k, _value):
self.actions.rotateRight.setEnabled(_value)
pix = cv2.imread(filename)
pix = np.rot90(pix, k)
cv2.imwrite(filename, pix)
self.canvas.update()
self.loadFile(filename)
def rotateImgWarn(self):
if self.lang == 'ch':
self.msgBox.warning (self, "提示", "\n 该图片已经有标注框,旋转操作会打乱标注,建议清除标注框后旋转。")
else:
self.msgBox.warning (self, "Warn", "\n The picture already has a label box, and rotation will disrupt the label.\
It is recommended to clear the label box and rotate it.")
def rotateLeftImg(self, _value=False):
filename = self.mImgList[self.currIndex]
if os.path.exists(filename):
if self.itemsToShapesbox:
self.rotateImgWarn()
else:
self.rotateImg(filename=filename, k=1, _value=True)
else:
self.rotateImgWarn()
self.actions.rotateRight.setEnabled(False)
def rotateRightImg(self, _value=False):
filename = self.mImgList[self.currIndex]
if os.path.exists(filename):
if self.itemsToShapesbox:
self.rotateImgWarn()
else:
self.rotateImg(filename=filename, k=-1, _value=True)
else:
self.rotateImgWarn()
self.actions.rotateRight.setEnabled(False)
def toggleDrawingSensitive(self, drawing=True): def toggleDrawingSensitive(self, drawing=True):
"""In the middle of drawing, toggling between modes should be disabled.""" """In the middle of drawing, toggling between modes should be disabled."""
self.actions.editMode.setEnabled(not drawing) self.actions.editMode.setEnabled(not drawing)
...@@ -885,7 +944,12 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -885,7 +944,12 @@ class MainWindow(QMainWindow, WindowMixin):
self.updateComboBox() self.updateComboBox()
def updateBoxlist(self): def updateBoxlist(self):
for shape in self.canvas.selectedShapes+[self.canvas.hShape]: self.canvas.selectedShapes_hShape = []
if self.canvas.hShape != None:
self.canvas.selectedShapes_hShape = self.canvas.selectedShapes + [self.canvas.hShape]
else:
self.canvas.selectedShapes_hShape = self.canvas.selectedShapes
for shape in self.canvas.selectedShapes_hShape:
item = self.shapesToItemsbox[shape] # listitem item = self.shapesToItemsbox[shape] # listitem
text = [(int(p.x()), int(p.y())) for p in shape.points] text = [(int(p.x()), int(p.y())) for p in shape.points]
item.setText(str(text)) item.setText(str(text))
...@@ -1274,7 +1338,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1274,7 +1338,7 @@ class MainWindow(QMainWindow, WindowMixin):
titem = self.iconlist.item(i) titem = self.iconlist.item(i)
titem.setSelected(True) titem.setSelected(True)
self.iconlist.scrollToItem(titem) self.iconlist.scrollToItem(titem)
break break
else: else:
self.fileListWidget.clear() self.fileListWidget.clear()
self.mImgList.clear() self.mImgList.clear()
...@@ -1282,7 +1346,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1282,7 +1346,7 @@ class MainWindow(QMainWindow, WindowMixin):
# if unicodeFilePath and self.iconList.count() > 0: # if unicodeFilePath and self.iconList.count() > 0:
# if unicodeFilePath in self.mImgList: # if unicodeFilePath in self.mImgList:
if unicodeFilePath and os.path.exists(unicodeFilePath): if unicodeFilePath and os.path.exists(unicodeFilePath):
self.canvas.verified = False self.canvas.verified = False
...@@ -1313,7 +1377,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1313,7 +1377,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.addRecentFile(self.filePath) self.addRecentFile(self.filePath)
self.toggleActions(True) self.toggleActions(True)
self.showBoundingBoxFromPPlabel(filePath) self.showBoundingBoxFromPPlabel(filePath)
self.setWindowTitle(__appname__ + ' ' + filePath) self.setWindowTitle(__appname__ + ' ' + filePath)
# Default : select last item if there is at least one item # Default : select last item if there is at least one item
...@@ -1325,7 +1389,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1325,7 +1389,7 @@ class MainWindow(QMainWindow, WindowMixin):
return True return True
return False return False
def showBoundingBoxFromPPlabel(self, filePath): def showBoundingBoxFromPPlabel(self, filePath):
imgidx = self.getImglabelidx(filePath) imgidx = self.getImglabelidx(filePath)
if imgidx not in self.PPlabel.keys(): if imgidx not in self.PPlabel.keys():
...@@ -1418,6 +1482,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1418,6 +1482,7 @@ class MainWindow(QMainWindow, WindowMixin):
def loadRecent(self, filename): def loadRecent(self, filename):
if self.mayContinue(): if self.mayContinue():
print(filename,"======")
self.loadFile(filename) self.loadFile(filename)
def scanAllImages(self, folderPath): def scanAllImages(self, folderPath):
...@@ -1453,6 +1518,22 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1453,6 +1518,22 @@ class MainWindow(QMainWindow, WindowMixin):
self.lastOpenDir = targetDirPath self.lastOpenDir = targetDirPath
self.importDirImages(targetDirPath) self.importDirImages(targetDirPath)
def openDatasetDirDialog(self,):
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.msgBox.warning(self, "提示", "\n 原文件夹已不存在,请从新选择数据集路径!")
else:
self.msgBox.warning(self, "Warn", "\n The original folder no longer exists, please choose the data set path again!")
self.actions.open_dataset_dir.setEnabled(False)
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
def importDirImages(self, dirpath, isDelete = False): def importDirImages(self, dirpath, isDelete = False):
if not self.mayContinue() or not dirpath: if not self.mayContinue() or not dirpath:
return return
...@@ -1500,6 +1581,10 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1500,6 +1581,10 @@ class MainWindow(QMainWindow, WindowMixin):
self.reRecogButton.setEnabled(True) self.reRecogButton.setEnabled(True)
self.actions.AutoRec.setEnabled(True) self.actions.AutoRec.setEnabled(True)
self.actions.reRec.setEnabled(True) self.actions.reRec.setEnabled(True)
self.actions.open_dataset_dir.setEnabled(True)
self.actions.rotateLeft.setEnabled(True)
self.actions.rotateRight.setEnabled(True)
def openPrevImg(self, _value=False): def openPrevImg(self, _value=False):
...@@ -1508,7 +1593,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1508,7 +1593,7 @@ class MainWindow(QMainWindow, WindowMixin):
if self.filePath is None: if self.filePath is None:
return return
currIndex = self.mImgList.index(self.filePath) currIndex = self.mImgList.index(self.filePath)
self.mImgList5 = self.mImgList[:5] self.mImgList5 = self.mImgList[:5]
if currIndex - 1 >= 0: if currIndex - 1 >= 0:
...@@ -1538,7 +1623,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1538,7 +1623,7 @@ class MainWindow(QMainWindow, WindowMixin):
if filename: if filename:
print('file name in openNext is ',filename) print('file name in openNext is ',filename)
self.loadFile(filename) self.loadFile(filename)
def updateFileListIcon(self, filename): def updateFileListIcon(self, filename):
pass pass
...@@ -1650,7 +1735,7 @@ class MainWindow(QMainWindow, WindowMixin): ...@@ -1650,7 +1735,7 @@ class MainWindow(QMainWindow, WindowMixin):
proc.startDetached(os.path.abspath(__file__)) proc.startDetached(os.path.abspath(__file__))
def mayContinue(self): # def mayContinue(self): #
if not self.dirty: if not self.dirty:
return True return True
else: else:
discardChanges = self.discardChangesDialog() discardChanges = self.discardChangesDialog()
...@@ -2077,7 +2162,7 @@ def main(): ...@@ -2077,7 +2162,7 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
resource_file = './libs/resources.py' resource_file = './libs/resources.py'
if not os.path.exists(resource_file): if not os.path.exists(resource_file):
output = os.system('pyrcc5 -o libs/resources.py resources.qrc') output = os.system('pyrcc5 -o libs/resources.py resources.qrc')
......
...@@ -23,6 +23,7 @@ except ImportError: ...@@ -23,6 +23,7 @@ except ImportError:
from libs.shape import Shape from libs.shape import Shape
from libs.utils import distance from libs.utils import distance
import copy
CURSOR_DEFAULT = Qt.ArrowCursor CURSOR_DEFAULT = Qt.ArrowCursor
CURSOR_POINT = Qt.PointingHandCursor CURSOR_POINT = Qt.PointingHandCursor
...@@ -81,6 +82,7 @@ class Canvas(QWidget): ...@@ -81,6 +82,7 @@ class Canvas(QWidget):
self.fourpoint = True # ADD self.fourpoint = True # ADD
self.pointnum = 0 self.pointnum = 0
self.movingShape = False self.movingShape = False
self.selectCountShape = False
#initialisation for panning #initialisation for panning
self.pan_initial_pos = QPoint() self.pan_initial_pos = QPoint()
...@@ -702,6 +704,10 @@ class Canvas(QWidget): ...@@ -702,6 +704,10 @@ class Canvas(QWidget):
def keyPressEvent(self, ev): def keyPressEvent(self, ev):
key = ev.key() key = ev.key()
shapesBackup = []
shapesBackup = copy.deepcopy(self.shapes)
self.shapesBackups.pop()
self.shapesBackups.append(shapesBackup)
if key == Qt.Key_Escape and self.current: if key == Qt.Key_Escape and self.current:
print('ESC press') print('ESC press')
self.current = None self.current = None
...@@ -709,43 +715,50 @@ class Canvas(QWidget): ...@@ -709,43 +715,50 @@ class Canvas(QWidget):
self.update() self.update()
elif key == Qt.Key_Return and self.canCloseShape(): elif key == Qt.Key_Return and self.canCloseShape():
self.finalise() self.finalise()
elif key == Qt.Key_Left and self.selectedShape: elif key == Qt.Key_Left and self.selectedShapes:
self.moveOnePixel('Left') self.moveOnePixel('Left')
elif key == Qt.Key_Right and self.selectedShape: elif key == Qt.Key_Right and self.selectedShapes:
self.moveOnePixel('Right') self.moveOnePixel('Right')
elif key == Qt.Key_Up and self.selectedShape: elif key == Qt.Key_Up and self.selectedShapes:
self.moveOnePixel('Up') self.moveOnePixel('Up')
elif key == Qt.Key_Down and self.selectedShape: elif key == Qt.Key_Down and self.selectedShapes:
self.moveOnePixel('Down') self.moveOnePixel('Down')
def moveOnePixel(self, direction): def moveOnePixel(self, direction):
# print(self.selectedShape.points) # print(self.selectedShape.points)
if direction == 'Left' and not self.moveOutOfBound(QPointF(-1.0, 0)): self.selectCount = len(self.selectedShapes)
# print("move Left one pixel") self.selectCountShape = True
self.selectedShape.points[0] += QPointF(-1.0, 0) for i in range(len(self.selectedShapes)):
self.selectedShape.points[1] += QPointF(-1.0, 0) self.selectedShape = self.selectedShapes[i]
self.selectedShape.points[2] += QPointF(-1.0, 0) if direction == 'Left' and not self.moveOutOfBound(QPointF(-1.0, 0)):
self.selectedShape.points[3] += QPointF(-1.0, 0) # print("move Left one pixel")
elif direction == 'Right' and not self.moveOutOfBound(QPointF(1.0, 0)): self.selectedShape.points[0] += QPointF(-1.0, 0)
# print("move Right one pixel") self.selectedShape.points[1] += QPointF(-1.0, 0)
self.selectedShape.points[0] += QPointF(1.0, 0) self.selectedShape.points[2] += QPointF(-1.0, 0)
self.selectedShape.points[1] += QPointF(1.0, 0) self.selectedShape.points[3] += QPointF(-1.0, 0)
self.selectedShape.points[2] += QPointF(1.0, 0) elif direction == 'Right' and not self.moveOutOfBound(QPointF(1.0, 0)):
self.selectedShape.points[3] += QPointF(1.0, 0) # print("move Right one pixel")
elif direction == 'Up' and not self.moveOutOfBound(QPointF(0, -1.0)): self.selectedShape.points[0] += QPointF(1.0, 0)
# print("move Up one pixel") self.selectedShape.points[1] += QPointF(1.0, 0)
self.selectedShape.points[0] += QPointF(0, -1.0) self.selectedShape.points[2] += QPointF(1.0, 0)
self.selectedShape.points[1] += QPointF(0, -1.0) self.selectedShape.points[3] += QPointF(1.0, 0)
self.selectedShape.points[2] += QPointF(0, -1.0) elif direction == 'Up' and not self.moveOutOfBound(QPointF(0, -1.0)):
self.selectedShape.points[3] += QPointF(0, -1.0) # print("move Up one pixel")
elif direction == 'Down' and not self.moveOutOfBound(QPointF(0, 1.0)): self.selectedShape.points[0] += QPointF(0, -1.0)
# print("move Down one pixel") self.selectedShape.points[1] += QPointF(0, -1.0)
self.selectedShape.points[0] += QPointF(0, 1.0) self.selectedShape.points[2] += QPointF(0, -1.0)
self.selectedShape.points[1] += QPointF(0, 1.0) self.selectedShape.points[3] += QPointF(0, -1.0)
self.selectedShape.points[2] += QPointF(0, 1.0) elif direction == 'Down' and not self.moveOutOfBound(QPointF(0, 1.0)):
self.selectedShape.points[3] += QPointF(0, 1.0) # print("move Down one pixel")
self.shapeMoved.emit() self.selectedShape.points[0] += QPointF(0, 1.0)
self.repaint() self.selectedShape.points[1] += QPointF(0, 1.0)
self.selectedShape.points[2] += QPointF(0, 1.0)
self.selectedShape.points[3] += QPointF(0, 1.0)
shapesBackup = []
shapesBackup = copy.deepcopy(self.shapes)
self.shapesBackups.append(shapesBackup)
self.shapeMoved.emit()
self.repaint()
def moveOutOfBound(self, step): def moveOutOfBound(self, step):
points = [p1+p2 for p1, p2 in zip(self.selectedShape.points, [step]*4)] points = [p1+p2 for p1, p2 in zip(self.selectedShape.points, [step]*4)]
...@@ -840,6 +853,10 @@ class Canvas(QWidget): ...@@ -840,6 +853,10 @@ class Canvas(QWidget):
def restoreShape(self): def restoreShape(self):
if not self.isShapeRestorable: if not self.isShapeRestorable:
return return
if self.selectCountShape:
if len(self.shapesBackups) > 2:
for i in range(1,self.selectCount):
self.shapesBackups.pop()
self.shapesBackups.pop() # latest self.shapesBackups.pop() # latest
shapesBackup = self.shapesBackups.pop() shapesBackup = self.shapesBackups.pop()
self.shapes = shapesBackup self.shapes = shapesBackup
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
<file alias="quit">resources/icons/quit.png</file> <file alias="quit">resources/icons/quit.png</file>
<file alias="copy">resources/icons/copy.png</file> <file alias="copy">resources/icons/copy.png</file>
<file alias="edit">resources/icons/edit.png</file> <file alias="edit">resources/icons/edit.png</file>
<file alias="rotateLeft">resources/icons/rotateLeft.png</file>
<file alias="rotateRight">resources/icons/rotateRight.png</file>
<file alias="open">resources/icons/open.png</file> <file alias="open">resources/icons/open.png</file>
<file alias="save">resources/icons/save.png</file> <file alias="save">resources/icons/save.png</file>
<file alias="format_voc">resources/icons/format_voc.png</file> <file alias="format_voc">resources/icons/format_voc.png</file>
......
...@@ -31,6 +31,7 @@ save=确认 ...@@ -31,6 +31,7 @@ save=确认
saveAs=另存为 saveAs=另存为
fitWinDetail=缩放到当前窗口大小 fitWinDetail=缩放到当前窗口大小
openDir=打开目录 openDir=打开目录
openDatasetDir=打开数据集路径
copyPrevBounding=复制当前图像中的上一个边界框 copyPrevBounding=复制当前图像中的上一个边界框
showHide=显示/隐藏标签 showHide=显示/隐藏标签
changeSaveFormat=更改存储格式 changeSaveFormat=更改存储格式
...@@ -85,6 +86,8 @@ detectionBoxposition=检测框位置 ...@@ -85,6 +86,8 @@ detectionBoxposition=检测框位置
recognitionResult=识别结果 recognitionResult=识别结果
creatPolygon=四点标注 creatPolygon=四点标注
drawSquares=正方形标注 drawSquares=正方形标注
rotateLeft=图片左旋转90度
rotateRight=图片右旋转90度
saveRec=保存识别结果 saveRec=保存识别结果
tempLabel=待识别 tempLabel=待识别
nullLabel=无法识别 nullLabel=无法识别
......
...@@ -3,6 +3,7 @@ openFileDetail=Open image or label file ...@@ -3,6 +3,7 @@ openFileDetail=Open image or label file
quit=Quit quit=Quit
quitApp=Quit application quitApp=Quit application
openDir=Open Dir openDir=Open Dir
openDatasetDir=Open DatasetDir
copyPrevBounding=Copy previous Bounding Boxes in the current image copyPrevBounding=Copy previous Bounding Boxes in the current image
changeSavedAnnotationDir=Change default saved Annotation dir changeSavedAnnotationDir=Change default saved Annotation dir
openAnnotation=Open Annotation openAnnotation=Open Annotation
...@@ -84,6 +85,8 @@ iconList=Icon List ...@@ -84,6 +85,8 @@ iconList=Icon List
detectionBoxposition=Detection box position detectionBoxposition=Detection box position
recognitionResult=Recognition result recognitionResult=Recognition result
creatPolygon=Create Quadrilateral creatPolygon=Create Quadrilateral
rotateLeft=Left turn 90 degrees
rotateRight=Right turn 90 degrees
drawSquares=Draw Squares drawSquares=Draw Squares
saveRec=Save Recognition Result saveRec=Save Recognition Result
tempLabel=TEMPORARY tempLabel=TEMPORARY
......
...@@ -7,4 +7,4 @@ tqdm ...@@ -7,4 +7,4 @@ tqdm
numpy numpy
visualdl visualdl
python-Levenshtein python-Levenshtein
opencv-contrib-python==4.2.0.32 opencv-contrib-python==4.4.0.46
\ No newline at end of file \ No newline at end of file
...@@ -51,7 +51,7 @@ def init_args(): ...@@ -51,7 +51,7 @@ def init_args():
parser.add_argument("--det_db_box_thresh", type=float, default=0.6) parser.add_argument("--det_db_box_thresh", type=float, default=0.6)
parser.add_argument("--det_db_unclip_ratio", type=float, default=1.5) parser.add_argument("--det_db_unclip_ratio", type=float, default=1.5)
parser.add_argument("--max_batch_size", type=int, default=10) parser.add_argument("--max_batch_size", type=int, default=10)
parser.add_argument("--use_dilation", type=bool, default=False) parser.add_argument("--use_dilation", type=str2bool, default=False)
parser.add_argument("--det_db_score_mode", type=str, default="fast") parser.add_argument("--det_db_score_mode", type=str, default="fast")
# EAST parmas # EAST parmas
parser.add_argument("--det_east_score_thresh", type=float, default=0.8) parser.add_argument("--det_east_score_thresh", type=float, default=0.8)
...@@ -61,7 +61,7 @@ def init_args(): ...@@ -61,7 +61,7 @@ def init_args():
# SAST parmas # SAST parmas
parser.add_argument("--det_sast_score_thresh", type=float, default=0.5) parser.add_argument("--det_sast_score_thresh", type=float, default=0.5)
parser.add_argument("--det_sast_nms_thresh", type=float, default=0.2) parser.add_argument("--det_sast_nms_thresh", type=float, default=0.2)
parser.add_argument("--det_sast_polygon", type=bool, default=False) parser.add_argument("--det_sast_polygon", type=str2bool, default=False)
# params for text recognizer # params for text recognizer
parser.add_argument("--rec_algorithm", type=str, default='CRNN') parser.add_argument("--rec_algorithm", type=str, default='CRNN')
...@@ -90,7 +90,7 @@ def init_args(): ...@@ -90,7 +90,7 @@ def init_args():
parser.add_argument( parser.add_argument(
"--e2e_char_dict_path", type=str, default="./ppocr/utils/ic15_dict.txt") "--e2e_char_dict_path", type=str, default="./ppocr/utils/ic15_dict.txt")
parser.add_argument("--e2e_pgnet_valid_set", type=str, default='totaltext') parser.add_argument("--e2e_pgnet_valid_set", type=str, default='totaltext')
parser.add_argument("--e2e_pgnet_polygon", type=bool, default=True) parser.add_argument("--e2e_pgnet_polygon", type=str2bool, default=True)
parser.add_argument("--e2e_pgnet_mode", type=str, default='fast') parser.add_argument("--e2e_pgnet_mode", type=str, default='fast')
# params for text classifier # params for text classifier
...@@ -111,7 +111,7 @@ def init_args(): ...@@ -111,7 +111,7 @@ def init_args():
parser.add_argument("--total_process_num", type=int, default=1) parser.add_argument("--total_process_num", type=int, default=1)
parser.add_argument("--process_id", type=int, default=0) parser.add_argument("--process_id", type=int, default=0)
parser.add_argument("--benchmark", type=bool, default=False) parser.add_argument("--benchmark", type=str2bool, default=False)
parser.add_argument("--save_log_path", type=str, default="./log_output/") parser.add_argument("--save_log_path", type=str, default="./log_output/")
parser.add_argument("--show_log", type=str2bool, default=True) parser.add_argument("--show_log", type=str2bool, default=True)
...@@ -210,22 +210,22 @@ def create_predictor(args, mode, logger): ...@@ -210,22 +210,22 @@ def create_predictor(args, mode, logger):
"nearest_interp_v2_0.tmp_0": [1, 256, 40, 40] "nearest_interp_v2_0.tmp_0": [1, 256, 40, 40]
} }
min_pact_shape = { min_pact_shape = {
"nearest_interp_v2_26.tmp_0":[1,256,20,20], "nearest_interp_v2_26.tmp_0": [1, 256, 20, 20],
"nearest_interp_v2_27.tmp_0":[1,64,20,20], "nearest_interp_v2_27.tmp_0": [1, 64, 20, 20],
"nearest_interp_v2_28.tmp_0":[1,64,20,20], "nearest_interp_v2_28.tmp_0": [1, 64, 20, 20],
"nearest_interp_v2_29.tmp_0":[1,64,20,20] "nearest_interp_v2_29.tmp_0": [1, 64, 20, 20]
} }
max_pact_shape = { max_pact_shape = {
"nearest_interp_v2_26.tmp_0":[1,256,400,400], "nearest_interp_v2_26.tmp_0": [1, 256, 400, 400],
"nearest_interp_v2_27.tmp_0":[1,64,400,400], "nearest_interp_v2_27.tmp_0": [1, 64, 400, 400],
"nearest_interp_v2_28.tmp_0":[1,64,400,400], "nearest_interp_v2_28.tmp_0": [1, 64, 400, 400],
"nearest_interp_v2_29.tmp_0":[1,64,400,400] "nearest_interp_v2_29.tmp_0": [1, 64, 400, 400]
} }
opt_pact_shape = { opt_pact_shape = {
"nearest_interp_v2_26.tmp_0":[1,256,160,160], "nearest_interp_v2_26.tmp_0": [1, 256, 160, 160],
"nearest_interp_v2_27.tmp_0":[1,64,160,160], "nearest_interp_v2_27.tmp_0": [1, 64, 160, 160],
"nearest_interp_v2_28.tmp_0":[1,64,160,160], "nearest_interp_v2_28.tmp_0": [1, 64, 160, 160],
"nearest_interp_v2_29.tmp_0":[1,64,160,160] "nearest_interp_v2_29.tmp_0": [1, 64, 160, 160]
} }
min_input_shape.update(min_pact_shape) min_input_shape.update(min_pact_shape)
max_input_shape.update(max_pact_shape) max_input_shape.update(max_pact_shape)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册