From 6f3491f03ce922d33f36765d2f4ecb2da93840e9 Mon Sep 17 00:00:00 2001 From: LinasKo Date: Thu, 31 Oct 2024 17:18:08 +0200 Subject: [PATCH] Fix issue in polygon_to_mask - expects a np.int32 datatype --- supervision/detection/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index a0a4d3e2..69cdacc7 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -25,8 +25,7 @@ def polygon_to_mask(polygon: np.ndarray, resolution_wh: Tuple[int, int]) -> np.n """ width, height = map(int, resolution_wh) mask = np.zeros((height, width), dtype=np.uint8) - - cv2.fillPoly(mask, [polygon], color=1) + cv2.fillPoly(mask, [polygon.astype(np.int32)], color=1) return mask