craete copies of mask in _has_holes and _mask_has_multiple_segments
This commit is contained in:
@@ -108,9 +108,8 @@ def coco_annotations_to_detections(
|
||||
|
||||
|
||||
def _mask_has_holes(mask: np.ndarray) -> bool:
|
||||
_, hierarchy = cv2.findContours(
|
||||
mask.astype(np.uint8), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE
|
||||
)
|
||||
mask_uint8 = mask.astype(np.uint8)
|
||||
_, hierarchy = cv2.findContours(mask_uint8, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
|
||||
parent_countour_index = 3
|
||||
for h in hierarchy[0]:
|
||||
if h[parent_countour_index] != -1:
|
||||
@@ -119,7 +118,8 @@ def _mask_has_holes(mask: np.ndarray) -> bool:
|
||||
|
||||
|
||||
def _mask_has_multiple_segments(mask: np.ndarray) -> bool:
|
||||
number_of_labels, _ = cv2.connectedComponents(mask.astype(np.uint8), connectivity=4)
|
||||
mask_uint8 = mask.astype(np.uint8)
|
||||
number_of_labels, _ = cv2.connectedComponents(mask_uint8, connectivity=4)
|
||||
return number_of_labels > 2
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user