(coordinate, with_label=True)
return np.array(boxes, dtype=np.float32)
:param coordinate: format [x1, y1, x2, y2, x3, y3, x4, y4, (label)]
    :param with_label: default True
    :return: format [x_c, y_c, w, h, theta, (label)]
:param coordinate: format [x1, y1, x2, y2, x3, y3, x4, y4, (label)]
    :param with_label: default True
    :return: format [x_c, y_c, w, h, theta, (label)]
: param coordinate : format [ x1 y1 x2 y2 x3 y3 x4 y4 ( label ) ] : param with_label : default True : return : format [ x_c y_c w h theta ( label ) ]
def backward_convert(coordinate, with_label=True):
    """
    :param coordinate: format [x1, y1, x2, y2, x3, y3, x4, y4, (label)]
    :param with_label: default True
    :return: format [x_c, y_c, w, h, theta, (label)]
    """

    boxes = []
    if with_label:
        for rect in coordinate:
            box = np.int0(rect[:-1])
            box = box.reshape([4, 2])
            rect1 = cv2.minAreaRect(box)

            x, y, w, h, theta = rect1[0][0], rect1[0][1], rect1[1][0], rect1[1][1], rect1[2]

            if theta == 0:
                w, h = h, w
                theta -= 90

            boxes.append([x, y, w, h, theta, rect[-1]])

    else:
        for rect in coordinate:
            box = np.int0(rect)
            box = box.reshape([4, 2])
            rect1 = cv2.minAreaRect(box)

            x, y, w, h, theta = rect1[0][0], rect1[0][1], rect1[1][0], rect1[1][1], rect1[2]

            if theta == 0:
                w, h = h, w
                theta -= 90

            boxes.append([x, y, w, h, theta])

    return np.array(boxes, dtype=np.float32)
def backward_convert ( coordinate , with_label = True ) : boxes = [ ] if with_label : for rect in coordinate : box = np . int0 ( rect [ : - 1 ] ) box = box . reshape ( [ 4 , 2 ] ) rect1 = cv2 . minAreaRect ( box ) x , y , w , h , theta = rect1 [ 0 ] [ 0 ] , rect1 [ 0 ] [ 1 ] , rect1 [ 1 ] [ 0 ] , rect1 [ 1 ] [ 1 ] , rect1 [ 2 ] if theta == 0 : w , h = h , w theta -= 90 boxes . append ( [ x , y , w , h , theta , rect [ - 1 ] ] ) else : for rect in coordinate : box = np . int0 ( rect ) box = box . reshape ( [ 4 , 2 ] ) rect1 = cv2 . minAreaRect ( box ) x , y , w , h , theta = rect1 [ 0 ] [ 0 ] , rect1 [ 0 ] [ 1 ] , rect1 [ 1 ] [ 0 ] , rect1 [ 1 ] [ 1 ] , rect1 [ 2 ] if theta == 0 : w , h = h , w theta -= 90 boxes . append ( [ x , y , w , h , theta ] ) return np . array ( boxes , dtype = np . float32 )