(polygon)
return order_points_clockwise(points)
对只有一个字符的框进行扩充
对只有一个字符的框进行扩充
对只有一个字符的框进行扩充
def expand_polygon(polygon):
    """
    对只有一个字符的框进行扩充
    """
    (x, y), (w, h), angle = cv2.minAreaRect(np.float32(polygon))
    if angle < -45:
        w, h = h, w
        angle += 90
    new_w = w + h
    box = ((x, y), (new_w, h), angle)
    points = cv2.boxPoints(box)
    return order_points_clockwise(points)
def expand_polygon ( polygon ) : ( x , y ) , ( w , h ) , angle = cv2 . minAreaRect ( np . float32 ( polygon ) ) if angle < - 45 : w , h = h , w angle += 90 new_w = w + h box = ( ( x , y ) , ( new_w , h ) , angle ) points = cv2 . boxPoints ( box ) return order_points_clockwise ( points )