Parse a PASCAL VOC xml file
(filename)
| 102 | |
| 103 | |
| 104 | def parse_rec(filename): |
| 105 | """ Parse a PASCAL VOC xml file """ |
| 106 | tree = ET.parse(filename) |
| 107 | objects = [] |
| 108 | for obj in tree.findall('object'): |
| 109 | obj_struct = {} |
| 110 | obj_struct['name'] = obj.find('name').text |
| 111 | obj_struct['pose'] = obj.find('pose').text |
| 112 | obj_struct['truncated'] = int(obj.find('truncated').text) |
| 113 | obj_struct['difficult'] = int(obj.find('difficult').text) |
| 114 | bbox = obj.find('bndbox') |
| 115 | obj_struct['bbox'] = [int(bbox.find('xmin').text) - 1, |
| 116 | int(bbox.find('ymin').text) - 1, |
| 117 | int(bbox.find('xmax').text) - 1, |
| 118 | int(bbox.find('ymax').text) - 1] |
| 119 | objects.append(obj_struct) |
| 120 | |
| 121 | return objects |
| 122 | |
| 123 | |
| 124 | def get_output_dir(name, phase): |