Skip to content

Commit 9ffcab4

Browse files
committed
Merge branch 'segmentation_handler' into developer
requirement matched"
2 parents 824e658 + 63798f4 commit 9ffcab4

File tree

13 files changed

+351
-326
lines changed

13 files changed

+351
-326
lines changed
File renamed without changes.
File renamed without changes.

labelvim/layout copy.py renamed to labelvim/Designer/layout.py

Lines changed: 73 additions & 199 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.
File renamed without changes.

labelvim/labelvim/utils/__init__.py

Whitespace-only changes.

labelvim/labelvim/utils/save_mask.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ def create_mask(image=None, annotations=None, label_map=None, include_img = Fals
8080
269
8181
],
8282
"area": 56759,
83-
"segmentation": [
83+
"segmentation": [[
8484
470,
8585
387,
8686
541,
8787
394,
8888
599,
89-
370
89+
370]
9090
],
9191
"iscrowd": 0
9292
}
@@ -98,11 +98,15 @@ def create_mask(image=None, annotations=None, label_map=None, include_img = Fals
9898
for annotation in annotations:
9999
if mask_type == 'polygon':
100100
segmentation = annotation['segmentation']
101-
segmentation = np.array(segmentation).reshape(-1, 2)
102-
segmentation = segmentation.astype(np.int32)
103-
cv2.fillPoly(mask, [segmentation], color=random_colors_palette[annotation['category_id']].tolist())
101+
for polygon in segmentation:
102+
polygon = np.array(polygon).reshape(-1, 2)
103+
polygon = polygon.astype(np.int32)
104+
cv2.fillPoly(mask, [polygon], color=random_colors_palette[annotation['category_id']].tolist())
104105
label = label_map[annotation['category_id']]
105-
cv2.putText(mask, label, (segmentation[0][0], segmentation[0][1]), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
106+
bbox = annotation['bbox']
107+
x, y, w, h = bbox
108+
cv2.rectangle(mask, (x, y), (x + w, y + h), random_colors_palette[annotation['category_id']].tolist(), 2)
109+
cv2.putText(mask, label, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
106110
elif mask_type == 'bbox':
107111
bbox = annotation['bbox']
108112
x, y, w, h = bbox

labelvim/labelvim/widgets/__init__.py

Whitespace-only changes.

labelvim/labelvim/widgets/canvas_widget.py

Lines changed: 155 additions & 89 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)