(filename)
return objects
Parse a PASCAL VOC xml file
Parse a PASCAL VOC xml file
Parse a PASCAL VOC xml file
def parse_rec(filename):
  """ Parse a PASCAL VOC xml file """
  tree = ET.parse(filename)
  objects = []
  for obj in tree.findall('object'):
    obj_struct = {}
    obj_struct['name'] = obj.find('name').text
    obj_struct['pose'] = obj.find('pose').text
    obj_struct['truncated'] = int(obj.find('truncated').text)
    obj_struct['difficult'] = int(obj.find('difficult').text)
    bbox = obj.find('bndbox')
    rbox = [int(bbox.find('x1').text), int(bbox.find('y1').text),
            int(bbox.find('x2').text), int(bbox.find('y2').text),
            int(bbox.find('x3').text), int(bbox.find('y3').text),
            int(bbox.find('x4').text), int(bbox.find('y4').text)]
    rbox = np.array([rbox], np.float32)
    rbox = coordinate_convert.backward_convert(rbox, with_label=False)
    obj_struct['bbox'] = rbox
    objects.append(obj_struct)

  return objects
def parse_rec ( filename ) : tree = ET . parse ( filename ) objects = [ ] for obj in tree . findall ( 'object' ) : obj_struct = { } obj_struct [ 'name' ] = obj . find ( 'name' ) . text obj_struct [ 'pose' ] = obj . find ( 'pose' ) . text obj_struct [ 'truncated' ] = int ( obj . find ( 'truncated' ) . text ) obj_struct [ 'difficult' ] = int ( obj . find ( 'difficult' ) . text ) bbox = obj . find ( 'bndbox' ) rbox = [ int ( bbox . find ( 'x1' ) . text ) , int ( bbox . find ( 'y1' ) . text ) , int ( bbox . find ( 'x2' ) . text ) , int ( bbox . find ( 'y2' ) . text ) , int ( bbox . find ( 'x3' ) . text ) , int ( bbox . find ( 'y3' ) . text ) , int ( bbox . find ( 'x4' ) . text ) , int ( bbox . find ( 'y4' ) . text ) ] rbox = np . array ( [ rbox ] , np . float32 ) rbox = coordinate_convert . backward_convert ( rbox , with_label = False ) obj_struct [ 'bbox' ] = rbox objects . append ( obj_struct ) return objects