提交 5c76adda 编写于 作者: K Kentaro Wada

Convert rectangle to polygon in labelme2coco.py

上级 ecf6362a
......@@ -110,7 +110,7 @@ def main():
points = shape['points']
label = shape['label']
group_id = shape.get('group_id')
shape_type = shape.get('shape_type')
shape_type = shape.get('shape_type', 'polygon')
mask = labelme.utils.shape_to_mask(
img.shape[:2], points, shape_type
)
......@@ -125,12 +125,14 @@ def main():
else:
masks[instance] = mask
points = np.asarray(points).flatten().tolist()
if shape['shape_type'] == 'rectangle':
x_1, y_1, x_2, y_2 = points
points = [x_1, y_1, x_2, y_1, x_2, y_2, x_1, y_2]
if shape_type == 'rectangle':
(x1, y1), (x2, y2) = points
x1, x2 = sorted([x1, x2])
y1, y2 = sorted([y1, y2])
points = [x1, y1, x2, y1, x2, y2, x1, y2]
else:
points = np.asarray(points).flatten().tolist()
segmentations[instance].append(points)
segmentations = dict(segmentations)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册