Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion imantics/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,14 @@ def coco(self, include=True):
if len(annotation['segmentation'][i]) == 2:
# discard segmentation that is only a point
annotation['segmentation'].pop(i)
i -= 1
elif len(annotation['segmentation'][i]) == 4:
# create another point in the middle of segmentation to
# avoid bug when using pycocotools, which thinks that a
# 4 value segmentation mask is a bounding box
polygon = annotation['segmentation'][i]
x1, y1, x2, y2 = polygon

if x2 == x1:
x = x1
y = (y2 + y1) // 2
Expand All @@ -304,7 +306,8 @@ def coco(self, include=True):

new_segmentation = polygon[:2] + [x, y] + polygon[2:]
annotation['segmentation'][i] = new_segmentation
i += 1

i += 1

if include:
image = category = {}
Expand Down