Open bjxia1 opened 5 years ago
bbox_masks = [] pos_mask = mask.copy() for bbox_idx, (bbox_xs, bbox_ys) in enumerate(zip(xs, ys)): if labels[bbox_idx] == background_label: continue bbox_mask = mask.copy() bbox_points = zip(bbox_xs, bbox_ys) bbox_contours = util.img.points_to_contours(bbox_points) util.img.draw_contours(bbox_mask, bbox_contours, idx = -1, color = 1, border_width = -1) bbox_masks.append(bbox_mask) if labels[bbox_idx] == text_label: pos_mask += bbox_mask # treat overlapped in-bbox pixels as negative, # and non-overlapped ones as positive pos_mask = np.asarray(pos_mask == 1, dtype = np.int32) num_positive_pixels = np.sum(pos_mask)
Here just draw contours and set contours to 1, but not set inside the contours to 1. I think here also need use cv2.fillPoly.
Here just draw contours and set contours to 1, but not set inside the contours to 1. I think here also need use cv2.fillPoly.