def get_bbox(height, width, points):
    """polygon to box

    Args:
        height (int): height of image
        width (int): width of image
        points (list): poly point [x, y]

    Returns:
        bbox (list): [x1, y1, w, h]
    """
    polygons = points
    mask = np.zeros([height, width], dtype=np.uint8)
    mask = Image.fromarray(mask)
    xy = list(map(tuple, polygons))
    ImageDraw.Draw(mask).polygon(xy=xy, outline=1, fill=1)
    mask = np.array(mask, dtype=bool)
    index = np.argwhere(mask == 1)
    rows = index[:, 0]
    clos = index[:, 1]
    left_top_r = np.min(rows)
    left_top_c = np.min(clos)
    right_bottom_r = np.max(rows)
    right_bottom_c = np.max(clos)
    return [
        left_top_c, left_top_r, right_bottom_c - left_top_c,
        right_bottom_r - left_top_r
    ]
polygon to box

    Args:
        height (int): height of image
        width (int): width of image
        points (list): poly point [x, y]

    Returns:
        bbox (list): [x1, y1, w, h]
    
contrib/QualityInspector/qinspector/utils/bbox_utils.py