Empty numpy array check

This commit is contained in:
Shubham Kanitkar 2023-08-18 13:09:55 -07:00
parent 6a2203c07a
commit 9ca1204a4c
1 changed files with 4 additions and 1 deletions

View File

@ -20,7 +20,10 @@ def polygon_to_mask(polygon: np.ndarray, resolution_wh: Tuple[int, int]) -> np.n
"""
width, height = resolution_wh
mask = np.zeros((height, width))
cv2.fillPoly(mask, [polygon], color=1)
# Empty numpy array check
if np.any(polygon):
cv2.fillPoly(mask, [polygon], color=1)
return mask