Add option to enable/disable label painting
This commit is contained in:
parent
219e50dbfc
commit
e7a7b64f7e
13
labelImg.py
13
labelImg.py
@ -370,6 +370,12 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.singleClassMode.setCheckable(True)
|
self.singleClassMode.setCheckable(True)
|
||||||
self.singleClassMode.setChecked(settings.get(SETTING_SINGLE_CLASS, False))
|
self.singleClassMode.setChecked(settings.get(SETTING_SINGLE_CLASS, False))
|
||||||
self.lastLabel = None
|
self.lastLabel = None
|
||||||
|
# Add option to enable/disable labels being painted at the top of bounding boxes
|
||||||
|
self.paintLabelsOption = QAction("Paint Labels", self)
|
||||||
|
self.paintLabelsOption.setShortcut("Ctrl+Shift+P")
|
||||||
|
self.paintLabelsOption.setCheckable(True)
|
||||||
|
self.paintLabelsOption.setChecked(False)
|
||||||
|
self.paintLabelsOption.triggered.connect(self.togglePaintLabelsOption)
|
||||||
|
|
||||||
addActions(self.menus.file,
|
addActions(self.menus.file,
|
||||||
(open, opendir, changeSavedir, openAnnotation, self.menus.recentFiles, save, save_format, saveAs, close, resetAll, quit))
|
(open, opendir, changeSavedir, openAnnotation, self.menus.recentFiles, save, save_format, saveAs, close, resetAll, quit))
|
||||||
@ -377,6 +383,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
addActions(self.menus.view, (
|
addActions(self.menus.view, (
|
||||||
self.autoSaving,
|
self.autoSaving,
|
||||||
self.singleClassMode,
|
self.singleClassMode,
|
||||||
|
self.paintLabelsOption,
|
||||||
labels, advancedMode, None,
|
labels, advancedMode, None,
|
||||||
hideAll, showAll, None,
|
hideAll, showAll, None,
|
||||||
zoomIn, zoomOut, zoomOrg, None,
|
zoomIn, zoomOut, zoomOrg, None,
|
||||||
@ -709,6 +716,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.actions.shapeFillColor.setEnabled(selected)
|
self.actions.shapeFillColor.setEnabled(selected)
|
||||||
|
|
||||||
def addLabel(self, shape):
|
def addLabel(self, shape):
|
||||||
|
shape.paintLabel = self.paintLabelsOption.isChecked()
|
||||||
item = HashableQListWidgetItem(shape.label)
|
item = HashableQListWidgetItem(shape.label)
|
||||||
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
|
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
|
||||||
item.setCheckState(Qt.Checked)
|
item.setCheckState(Qt.Checked)
|
||||||
@ -1399,7 +1407,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.loadLabels(shapes)
|
self.loadLabels(shapes)
|
||||||
self.canvas.verified = tYoloParseReader.verified
|
self.canvas.verified = tYoloParseReader.verified
|
||||||
|
|
||||||
|
def togglePaintLabelsOption(self):
|
||||||
|
paintLabelsOptionChecked = self.paintLabelsOption.isChecked()
|
||||||
|
for shape in self.canvas.shapes:
|
||||||
|
shape.paintLabel = paintLabelsOptionChecked
|
||||||
|
|
||||||
def inverted(color):
|
def inverted(color):
|
||||||
return QColor(*[255 - v for v in color.getRgb()])
|
return QColor(*[255 - v for v in color.getRgb()])
|
||||||
|
|||||||
@ -37,12 +37,13 @@ class Shape(object):
|
|||||||
point_size = 8
|
point_size = 8
|
||||||
scale = 1.0
|
scale = 1.0
|
||||||
|
|
||||||
def __init__(self, label=None, line_color=None,difficult = False):
|
def __init__(self, label=None, line_color=None, difficult=False, paintLabel=False):
|
||||||
self.label = label
|
self.label = label
|
||||||
self.points = []
|
self.points = []
|
||||||
self.fill = False
|
self.fill = False
|
||||||
self.selected = False
|
self.selected = False
|
||||||
self.difficult = difficult
|
self.difficult = difficult
|
||||||
|
self.paintLabel = paintLabel
|
||||||
|
|
||||||
self._highlightIndex = None
|
self._highlightIndex = None
|
||||||
self._highlightMode = self.NEAR_VERTEX
|
self._highlightMode = self.NEAR_VERTEX
|
||||||
@ -110,6 +111,7 @@ class Shape(object):
|
|||||||
painter.fillPath(vrtx_path, self.vertex_fill_color)
|
painter.fillPath(vrtx_path, self.vertex_fill_color)
|
||||||
|
|
||||||
# Draw text at the top-left
|
# Draw text at the top-left
|
||||||
|
if self.paintLabel:
|
||||||
min_x = sys.maxsize
|
min_x = sys.maxsize
|
||||||
min_y = sys.maxsize
|
min_y = sys.maxsize
|
||||||
for point in self.points:
|
for point in self.points:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user