Closed lrfighting closed 2 years ago
试试这个函数,把img和boxes传进去
def draw(img, boxes): mask = np.zeros(img.shape, dtype=np.uint8) for box in boxes: rand_r = random.randint(100, 255) rand_g = random.randint(100, 255) rand_b = random.randint(100, 255) mask = cv2.fillPoly(mask, [box], color=(rand_r, rand_g, rand_b)) img[mask!=0] = (0.6 * mask + 0.4 * img).astype(np.uint8)[mask!=0] for box in boxes: cv2.drawContours(img, [box], -1, (0, 255, 0), 2) return img
试试这个函数,把img和boxes传进去