Kentaro Wada 5 роки тому
батько
коміт
025ed3d78d

+ 2 - 54
labelme/app.py

@@ -19,7 +19,6 @@ from labelme.label_file import LabelFile
 from labelme.label_file import LabelFileError
 from labelme.logger import logger
 from labelme.shape import DEFAULT_FILL_COLOR
-from labelme.shape import DEFAULT_LINE_COLOR
 from labelme.shape import Shape
 from labelme.widgets import Canvas
 from labelme.widgets import ColorDialog
@@ -254,9 +253,6 @@ class MainWindow(QtWidgets.QMainWindow):
 
         close = action('&Close', self.closeFile, shortcuts['close'], 'close',
                        'Close current file')
-        color1 = action('Polygon &Line Color', self.chooseColor1,
-                        shortcuts['edit_line_color'], 'color-line',
-                        'Choose polygon line color')
         color2 = action('Polygon &Fill Color', self.chooseColor2,
                         shortcuts['edit_fill_color'], 'color',
                         self.tr('Choose polygon fill color'))
@@ -420,12 +416,6 @@ class MainWindow(QtWidgets.QMainWindow):
                       self.tr('Modify the label of the selected polygon'),
                       enabled=False)
 
-        shapeLineColor = action(
-            self.tr('Shape &Line Color'), self.chshapeLineColor,
-            icon='color-line',
-            tip=self.tr('Change the line color for this specific shape'),
-            enabled=False
-        )
         shapeFillColor = action(
             self.tr('Shape &Fill Color'), self.chshapeFillColor, icon='color',
             tip=self.tr('Change the fill color for this specific shape'),
@@ -456,7 +446,7 @@ class MainWindow(QtWidgets.QMainWindow):
             changeOutputDir=changeOutputDir,
             save=save, saveAs=saveAs, open=open_, close=close,
             deleteFile=deleteFile,
-            lineColor=color1, fillColor=color2,
+            fillColor=color2,
             toggleKeepPrevMode=toggle_keep_prev_mode,
             delete=delete, edit=edit, copy=copy,
             undoLastPoint=undoLastPoint, undo=undo,
@@ -467,7 +457,7 @@ class MainWindow(QtWidgets.QMainWindow):
             createLineMode=createLineMode,
             createPointMode=createPointMode,
             createLineStripMode=createLineStripMode,
-            shapeLineColor=shapeLineColor, shapeFillColor=shapeFillColor,
+            shapeFillColor=shapeFillColor,
             zoom=zoom, zoomIn=zoomIn, zoomOut=zoomOut, zoomOrg=zoomOrg,
             fitWindow=fitWindow, fitWidth=fitWidth,
             zoomActions=zoomActions,
@@ -485,7 +475,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 None,
                 addPointToEdge,
                 None,
-                color1,
                 color2,
                 None,
                 toggle_keep_prev_mode,
@@ -502,7 +491,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 edit,
                 copy,
                 delete,
-                shapeLineColor,
                 shapeFillColor,
                 undo,
                 undoLastPoint,
@@ -629,7 +617,6 @@ class MainWindow(QtWidgets.QMainWindow):
         self.imagePath = None
         self.recentFiles = []
         self.maxRecent = 7
-        self.lineColor = None
         self.fillColor = None
         self.otherData = None
         self.zoom_level = 100
@@ -662,11 +649,8 @@ class MainWindow(QtWidgets.QMainWindow):
         # self.restoreGeometry(settings['window/geometry']
         self.restoreState(
             self.settings.value('window/state', QtCore.QByteArray()))
-        self.lineColor = QtGui.QColor(
-            self.settings.value('line/color', Shape.line_color))
         self.fillColor = QtGui.QColor(
             self.settings.value('fill/color', Shape.fill_color))
-        Shape.line_color = self.lineColor
         Shape.fill_color = self.fillColor
 
         # Populate the File menu dynamically.
@@ -987,7 +971,6 @@ class MainWindow(QtWidgets.QMainWindow):
         self.actions.delete.setEnabled(n_selected)
         self.actions.copy.setEnabled(n_selected)
         self.actions.edit.setEnabled(n_selected == 1)
-        self.actions.shapeLineColor.setEnabled(n_selected)
         self.actions.shapeFillColor.setEnabled(n_selected)
 
     def addLabel(self, shape):
@@ -1021,7 +1004,6 @@ class MainWindow(QtWidgets.QMainWindow):
         for shape in shapes:
             label = shape['label']
             points = shape['points']
-            line_color = shape['line_color']
             fill_color = shape['fill_color']
             shape_type = shape['shape_type']
             flags = shape['flags']
@@ -1031,9 +1013,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 shape.addPoint(QtCore.QPointF(x, y))
             shape.close()
 
-            if line_color:
-                shape.line_color = QtGui.QColor(*line_color)
-
             if fill_color:
                 shape.fill_color = QtGui.QColor(*fill_color)
 
@@ -1063,8 +1042,6 @@ class MainWindow(QtWidgets.QMainWindow):
         def format_shape(s):
             return dict(
                 label=s.label.encode('utf-8') if PY2 else s.label,
-                line_color=s.line_color.getRgb()
-                if s.line_color != self.lineColor else None,
                 fill_color=s.fill_color.getRgb()
                 if s.fill_color != self.fillColor else None,
                 points=[(p.x(), p.y()) for p in s.points],
@@ -1092,7 +1069,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 imageData=imageData,
                 imageHeight=self.image.height(),
                 imageWidth=self.image.width(),
-                lineColor=self.lineColor.getRgb(),
                 fillColor=self.fillColor.getRgb(),
                 otherData=self.otherData,
                 flags=flags,
@@ -1291,8 +1267,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 osp.dirname(label_file),
                 self.labelFile.imagePath,
             )
-            if self.labelFile.lineColor is not None:
-                self.lineColor = QtGui.QColor(*self.labelFile.lineColor)
             if self.labelFile.fillColor is not None:
                 self.fillColor = QtGui.QColor(*self.labelFile.fillColor)
             self.otherData = self.labelFile.otherData
@@ -1396,7 +1370,6 @@ class MainWindow(QtWidgets.QMainWindow):
         self.settings.setValue('window/size', self.size())
         self.settings.setValue('window/position', self.pos())
         self.settings.setValue('window/state', self.saveState())
-        self.settings.setValue('line/color', self.lineColor)
         self.settings.setValue('fill/color', self.fillColor)
         self.settings.setValue('recentFiles', self.recentFiles)
         # ask the use for where to save the labels
@@ -1642,19 +1615,6 @@ class MainWindow(QtWidgets.QMainWindow):
     def currentPath(self):
         return osp.dirname(str(self.filename)) if self.filename else '.'
 
-    def chooseColor1(self):
-        color = self.colorDialog.getColor(
-            self.lineColor,
-            self.tr('Choose line color'),
-            default=DEFAULT_LINE_COLOR
-        )
-        if color:
-            self.lineColor = color
-            # Change the color for all shape lines:
-            Shape.line_color = self.lineColor
-            self.canvas.update()
-            self.setDirty()
-
     def chooseColor2(self):
         color = self.colorDialog.getColor(
             self.fillColor,
@@ -1685,18 +1645,6 @@ class MainWindow(QtWidgets.QMainWindow):
                 for action in self.actions.onShapesPresent:
                     action.setEnabled(False)
 
-    def chshapeLineColor(self):
-        color = self.colorDialog.getColor(
-            self.lineColor,
-            self.tr('Choose line color'),
-            default=DEFAULT_LINE_COLOR
-        )
-        if color:
-            for shape in self.canvas.selectedShapes:
-                shape.line_color = color
-            self.canvas.update()
-            self.setDirty()
-
     def chshapeFillColor(self):
         color = self.colorDialog.getColor(
             self.fillColor,

+ 0 - 1
labelme/config/default_config.yaml

@@ -81,6 +81,5 @@ shortcuts:
   undo_last_point: [Ctrl+Z, Backspace]
   add_point_to_edge: Ctrl+Shift+P
   edit_label: Ctrl+E
-  edit_line_color: Ctrl+L
   edit_fill_color: Ctrl+Shift+L
   toggle_keep_prev_mode: Ctrl+P

+ 0 - 6
labelme/label_file.py

@@ -59,7 +59,6 @@ class LabelFile(object):
             'version',
             'imageData',
             'imagePath',
-            'lineColor',
             'fillColor',
             'shapes',  # polygonal annotations
             'flags',   # image level flags
@@ -84,13 +83,11 @@ class LabelFile(object):
                 data.get('imageHeight'),
                 data.get('imageWidth'),
             )
-            lineColor = data['lineColor']
             fillColor = data['fillColor']
             shapes = [
                 dict(
                     label=s['label'],
                     points=s['points'],
-                    line_color=s['line_color'],
                     fill_color=s['fill_color'],
                     shape_type=s.get('shape_type', 'polygon'),
                     flags=s.get('flags', {}),
@@ -110,7 +107,6 @@ class LabelFile(object):
         self.shapes = shapes
         self.imagePath = imagePath
         self.imageData = imageData
-        self.lineColor = lineColor
         self.fillColor = fillColor
         self.filename = filename
         self.otherData = otherData
@@ -140,7 +136,6 @@ class LabelFile(object):
         imageHeight,
         imageWidth,
         imageData=None,
-        lineColor=None,
         fillColor=None,
         otherData=None,
         flags=None,
@@ -158,7 +153,6 @@ class LabelFile(object):
             version=__version__,
             flags=flags,
             shapes=shapes,
-            lineColor=lineColor,
             fillColor=fillColor,
             imagePath=imagePath,
             imageData=imageData,

+ 1 - 7
labelme/widgets/canvas.py

@@ -52,13 +52,12 @@ class Canvas(QtWidgets.QWidget):
         self.current = None
         self.selectedShapes = []  # save the selected shapes here
         self.selectedShapesCopy = []
-        self.lineColor = QtGui.QColor(0, 0, 255)
         # self.line represents:
         #   - createMode == 'polygon': edge from last point to current
         #   - createMode == 'rectangle': diagonal line of the rectangle
         #   - createMode == 'line': the line
         #   - createMode == 'point': the point
-        self.line = Shape(line_color=self.lineColor)
+        self.line = Shape()
         self.prevPoint = QtCore.QPoint()
         self.prevMovePoint = QtCore.QPoint()
         self.offsets = QtCore.QPoint(), QtCore.QPoint()
@@ -178,7 +177,6 @@ class Canvas(QtWidgets.QWidget):
             if not self.current:
                 return
 
-            color = self.lineColor
             if self.outOfPixmap(pos):
                 # Don't allow the user to draw outside the pixmap.
                 # Project the point to the pixmap's edges.
@@ -188,7 +186,6 @@ class Canvas(QtWidgets.QWidget):
                 # Attract line to starting point and
                 # colorise to alert the user.
                 pos = self.current[0]
-                color = self.current.line_color
                 self.overrideCursor(CURSOR_POINT)
                 self.current.highlightVertex(0, Shape.NEAR_VERTEX)
             if self.createMode in ['polygon', 'linestrip']:
@@ -206,7 +203,6 @@ class Canvas(QtWidgets.QWidget):
             elif self.createMode == 'point':
                 self.line.points = [self.current[0]]
                 self.line.close()
-            self.line.line_color = color
             self.repaint()
             self.current.highlightClear()
             return
@@ -375,8 +371,6 @@ class Canvas(QtWidgets.QWidget):
     def endMove(self, copy):
         assert self.selectedShapes and self.selectedShapesCopy
         assert len(self.selectedShapesCopy) == len(self.selectedShapes)
-        # del shape.fill_color
-        # del shape.line_color
         if copy:
             for i, shape in enumerate(self.selectedShapesCopy):
                 self.shapes.append(shape)