如何使用cv2.drawContours从numpy点数组绘制填充轮廓?

时间:2018-12-10 13:25:34

标签: python opencv computer-vision scikit-image

如何使用cv2.drawContours从numpy点数组绘制填充轮廓

由于某些原因,此代码绘制单个点而不填充轮廓:

ctr = np.array(pts).reshape((-1, 1, 2)).astype(np.int32)
mask = cv2.drawContours(mask, ctr, contourIdx=-1, color=1, thickness=-1)

使用skimage我可以做到:

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)

0 个答案:

没有答案