(xml_path)
return img_height, img_width, gtbox_label
:param xml_path: the path of voc xml
    :return: a list contains gtboxes and labels, shape is [num_of_gtboxes, 9],
           and has [x1, y1, x2, y2, x3, y3, x4, y4, label] in a per row
:param xml_path: the path of voc xml
    :return: a list contains gtboxes and labels, shape is [num_of_gtboxes, 9],
           and has [x1, y1, x2, y2, x3, y3, x4, y4, label] in a per row
: param xml_path : the path of voc xml : return : a list contains gtboxes and labels shape is [ num_of_gtboxes 9 ] and has [ x1 y1 x2 y2 x3 y3 x4 y4 label ] in a per row
def read_xml_gtbox_and_label(xml_path):
    """
    :param xml_path: the path of voc xml
    :return: a list contains gtboxes and labels, shape is [num_of_gtboxes, 9],
           and has [x1, y1, x2, y2, x3, y3, x4, y4, label] in a per row
    """

    tree = ET.parse(xml_path)
    root = tree.getroot()
    img_width = None
    img_height = None
    box_list = []
    for child_of_root in root:
        # if child_of_root.tag == 'filename':
        #     assert child_of_root.text == xml_path.split('/')[-1].split('.')[0] \
        #                                  + FLAGS.img_format, 'xml_name and img_name cannot match'

        # if child_of_root.tag == 'size':
        #     for child_item in child_of_root:
        #         if child_item.tag == 'width':
        #             img_width = int(child_item.text)
        #         if child_item.tag == 'height':
        #             img_height = int(child_item.text)
        #
        # if child_of_root.tag == 'object':
        #     label = None
        #     for child_item in child_of_root:
        #         if child_item.tag == 'name':
        #             label = NAME_LABEL_MAP[child_item.text]
        #         if child_item.tag == 'bndbox':
        #             tmp_box = []
        #             for node in child_item:
        #                 tmp_box.append(float(node.text))
        #             assert label is not None, 'label is none, error'
        #             tmp_box.append(label)
        #             box_list.append(tmp_box)

        # ship
        if child_of_root.tag == 'Img_SizeWidth':
            img_width = int(child_of_root.text)
        if child_of_root.tag == 'Img_SizeHeight':
            img_height = int(child_of_root.text)
        if child_of_root.tag == 'HRSC_Objects':
            box_list = []
            for child_item in child_of_root:
                if child_item.tag == 'HRSC_Object':
                    label = 1
                    # for child_object in child_item:
                    #     if child_object.tag == 'Class_ID':
                    #         label = NAME_LABEL_MAP[child_object.text]
                    tmp_box = [0., 0., 0., 0., 0.]
                    for node in child_item:
                        if node.tag == 'mbox_cx':
                            tmp_box[0] = float(node.text)
                        if node.tag == 'mbox_cy':
                            tmp_box[1] = float(node.text)
                        if node.tag == 'mbox_w':
                            tmp_box[2] = float(node.text)
                        if node.tag == 'mbox_h':
                            tmp_box[3] = float(node.text)
                        if node.tag == 'mbox_ang':
                            tmp_box[4] = float(node.text)

                    tmp_box = coordinate_convert_r(tmp_box)
                        # assert label is not None, 'label is none, error'
                    tmp_box.append(label)
                    # if len(tmp_box) != 0:
                    box_list.append(tmp_box)
            # box_list = coordinate_convert(box_list)
            # print(box_list)
    gtbox_label = np.array(box_list, dtype=np.int32)

    return img_height, img_width, gtbox_label
def read_xml_gtbox_and_label ( xml_path ) : tree = ET . parse ( xml_path ) root = tree . getroot ( ) img_width = None img_height = None box_list = [ ] for child_of_root in root : # if child_of_root.tag == 'filename': #     assert child_of_root.text == xml_path.split('/')[-1].split('.')[0] \ #                                  + FLAGS.img_format, 'xml_name and img_name cannot match' # if child_of_root.tag == 'size': #     for child_item in child_of_root: #         if child_item.tag == 'width': #             img_width = int(child_item.text) #         if child_item.tag == 'height': #             img_height = int(child_item.text) # # if child_of_root.tag == 'object': #     label = None #     for child_item in child_of_root: #         if child_item.tag == 'name': #             label = NAME_LABEL_MAP[child_item.text] #         if child_item.tag == 'bndbox': #             tmp_box = [] #             for node in child_item: #                 tmp_box.append(float(node.text)) #             assert label is not None, 'label is none, error' #             tmp_box.append(label) #             box_list.append(tmp_box) # ship if child_of_root . tag == 'Img_SizeWidth' : img_width = int ( child_of_root . text ) if child_of_root . tag == 'Img_SizeHeight' : img_height = int ( child_of_root . text ) if child_of_root . tag == 'HRSC_Objects' : box_list = [ ] for child_item in child_of_root : if child_item . tag == 'HRSC_Object' : label = 1 # for child_object in child_item: #     if child_object.tag == 'Class_ID': #         label = NAME_LABEL_MAP[child_object.text] tmp_box = [ 0. , 0. , 0. , 0. , 0. ] for node in child_item : if node . tag == 'mbox_cx' : tmp_box [ 0 ] = float ( node . text ) if node . tag == 'mbox_cy' : tmp_box [ 1 ] = float ( node . text ) if node . tag == 'mbox_w' : tmp_box [ 2 ] = float ( node . text ) if node . tag == 'mbox_h' : tmp_box [ 3 ] = float ( node . text ) if node . tag == 'mbox_ang' : tmp_box [ 4 ] = float ( node . text ) tmp_box = coordinate_convert_r ( tmp_box ) # assert label is not None, 'label is none, error' tmp_box . append ( label ) # if len(tmp_box) != 0: box_list . append ( tmp_box ) # box_list = coordinate_convert(box_list) # print(box_list) gtbox_label = np . array ( box_list , dtype = np . int32 ) return img_height , img_width , gtbox_label