(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(int(node.text))
                    assert label is not None, 'label is none, error'
                    tmp_box.append(label)
                    box_list.append(tmp_box)

    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 ( int ( node . text ) ) assert label is not None , 'label is none, error' tmp_box . append ( label ) box_list . append ( tmp_box ) gtbox_label = np . array ( box_list , dtype = np . int32 ) return img_height , img_width , gtbox_label