whai362 / pan_pp.pytorch

Official implementations of PSENet, PAN and PAN++.
Apache License 2.0
439 stars 90 forks source link

请问一下作者,我要如何能够像论文里面那样将 检测的文本实例框出来, #86

Closed lrfighting closed 2 years ago

czczup commented 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