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

Use shapes as list of dictionary

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