def _post_to_mask(self, rois, id):
for r in rois:
if 'rec' in r:
x1,y1,x2,y2 = r['rec']
for x in range(self.mask.shape[0]):
for y in range(self.mask.shape[1]):
if (x >= x1 and x < x2) and (y >= y1 and y < y2):
self.mask[x,y] = id
if 'poly' in r:
import matplotlib.patches as patches
poly1 = patches.Polygon(r['poly'], closed=True)
for i in range(self.mask.shape[0]):
for j in range(self.mask.shape[1]):
if poly1.get_path().contains_point((i,j)) == True:
self.mask[i,j] = id
评论列表
文章目录