How to draw filled contour from numpy array of points using cv2.drawContours
For some reason this code draw single points and not filled contour:
ctr = np.array(pts).reshape((-1, 1, 2)).astype(np.int32)
mask = cv2.drawContours(mask, ctr, contourIdx=-1, color=1, thickness=-1)
Using skimage I can do it like:
from skimage.draw import polygon
mask = mask.astype(np.uint8)
rr, cc = polygon(pts[:, 1], pts[:, 0], mask.shape)
mask[rr, cc] = 1
mask = mask.astype(np.float32)