提交 862e0b04 编写于 作者: K Kentaro Wada

Add shape_color, label_colors config

```
labelme data_annotated --labels labels.txt --config
  '{shape_color: manual, label_colors: {person: [0, 0, 255]}, default_shape_color: [255,0,0]}'
```
上级 48a3c573
......@@ -974,11 +974,20 @@ class MainWindow(QtWidgets.QMainWindow):
for action in self.actions.onShapesPresent:
action.setEnabled(True)
r, g, b = self._get_rgb_by_label(shape.label)
if self._config['shape_color'] == 'auto':
r, g, b = self._get_rgb_by_label(shape.label)
elif (self._config['shape_color'] == 'manual' and
self._config['label_colors'] and
shape.label in self._config['label_colors']):
r, g, b = self._config['label_colors'][shape.label]
elif self._config['default_shape_color']:
r, g, b = self._config['default_shape_color']
else:
return
shape.line_color = QtGui.QColor(r, g, b)
shape.vertex_fill_color = QtGui.QColor(r, g, b)
shape.hvertex_fill_color = QtGui.QColor(255, 255, 255)
shape.fill_color = QtGui.QColor(r, g, b, 127)
shape.fill_color = QtGui.QColor(r, g, b, 128)
shape.select_line_color = QtGui.QColor(255, 255, 255)
shape.select_fill_color = QtGui.QColor(r, g, b, 155)
......
......@@ -49,6 +49,11 @@ def validate_config_item(key, value):
"Unexpected value for config key 'validate_label': {}"
.format(value)
)
if key == 'shape_color' and value not in [None, 'auto', 'manual']:
raise ValueError(
"Unexpected value for config key 'shape_color': {}"
.format(value)
)
if key == 'labels' and value is not None and len(value) != len(set(value)):
raise ValueError(
"Duplicates are detected for config key 'labels': {}".format(value)
......
......@@ -13,6 +13,10 @@ file_search: null
sort_labels: true
validate_label: null
default_shape_color: null
shape_color: auto # null, 'auto', 'manual'
label_colors: null
# main
flag_dock:
show: true
......
......@@ -11,12 +11,13 @@ import labelme.utils
# - [opt] Store paths instead of creating new ones at each paint.
DEFAULT_LINE_COLOR = QtGui.QColor(0, 255, 0, 128) # before hovering
DEFAULT_FILL_COLOR = QtGui.QColor(255, 0, 0, 128) # hovering
DEFAULT_SELECT_LINE_COLOR = QtGui.QColor(255, 255, 255) # selected
DEFAULT_SELECT_FILL_COLOR = QtGui.QColor(0, 128, 255, 155) # selected
DEFAULT_VERTEX_FILL_COLOR = QtGui.QColor(0, 255, 0, 255) # hovering
DEFAULT_HVERTEX_FILL_COLOR = QtGui.QColor(255, 0, 0, 255) # hovering
R, G, B = SHAPE_COLOR = 0, 255, 0 # green
DEFAULT_LINE_COLOR = QtGui.QColor(R, G, B, 128) # bf hovering
DEFAULT_FILL_COLOR = QtGui.QColor(R, G, B, 128) # hovering
DEFAULT_SELECT_LINE_COLOR = QtGui.QColor(255, 255, 255) # selected
DEFAULT_SELECT_FILL_COLOR = QtGui.QColor(R, G, B, 155) # selected
DEFAULT_VERTEX_FILL_COLOR = QtGui.QColor(R, G, B, 255) # hovering
DEFAULT_HVERTEX_FILL_COLOR = QtGui.QColor(255, 255, 255, 255) # hovering
class Shape(object):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册