提交 34c88be4 编写于 作者: K Kentaro Wada

Use shapes as list of dictionary

上级 9ed44c85
...@@ -1011,7 +1011,14 @@ class MainWindow(QtWidgets.QMainWindow): ...@@ -1011,7 +1011,14 @@ class MainWindow(QtWidgets.QMainWindow):
def loadLabels(self, shapes): def loadLabels(self, shapes):
s = [] s = []
for label, points, line_color, fill_color, shape_type, flags in shapes: 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']
shape = Shape(label=label, shape_type=shape_type) shape = Shape(label=label, shape_type=shape_type)
for x, y in points: for x, y in points:
shape.addPoint(QtCore.QPointF(x, y)) shape.addPoint(QtCore.QPointF(x, y))
......
...@@ -21,7 +21,7 @@ class LabelFile(object): ...@@ -21,7 +21,7 @@ class LabelFile(object):
suffix = '.json' suffix = '.json'
def __init__(self, filename=None): def __init__(self, filename=None):
self.shapes = () self.shapes = []
self.imagePath = None self.imagePath = None
self.imageData = None self.imageData = None
if filename is not None: if filename is not None:
...@@ -82,17 +82,17 @@ class LabelFile(object): ...@@ -82,17 +82,17 @@ class LabelFile(object):
) )
lineColor = data['lineColor'] lineColor = data['lineColor']
fillColor = data['fillColor'] fillColor = data['fillColor']
shapes = ( shapes = [
( dict(
s['label'], label=s['label'],
s['points'], points=s['points'],
s['line_color'], line_color=s['line_color'],
s['fill_color'], fill_color=s['fill_color'],
s.get('shape_type', 'polygon'), shape_type=s.get('shape_type', 'polygon'),
s.get('flags', {}), flags=s.get('flags', {}),
) )
for s in data['shapes'] for s in data['shapes']
) ]
except Exception as e: except Exception as e:
raise LabelFileError(e) raise LabelFileError(e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册