Skip to content

Commit 2304c38

Browse files
committed
Fix logic in case of absence of nested contours
1 parent 3018059 commit 2304c38

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/python/model_api/models/segmentation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ def get_contours(
215215
hierarchy = hierarchy.squeeze()
216216

217217
for i, contour in enumerate(contours):
218-
children = None
219-
220218
if hierarchy[i][3] >= 0:
221219
continue
222220

@@ -226,6 +224,10 @@ def get_contours(
226224
while child_next_idx >= 0:
227225
children.append(contours[child_next_idx])
228226
child_next_idx = hierarchy[child_next_idx][0]
227+
228+
if not children:
229+
children = None
230+
229231
mask = np.zeros(prediction.resultImage.shape, dtype=np.uint8)
230232
cv2.drawContours(
231233
mask,

0 commit comments

Comments
 (0)