From 162ddae56908526139e08790a058e000a65613d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Jan 2020 10:29:56 +0000 Subject: [PATCH] Changed bounding box coordinates from int to float in python pascal_voc_xml2json --- src/python/pascal_voc_xml2json/pascal_voc_xml2json.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py b/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py index 65137b0..84c857d 100644 --- a/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py +++ b/src/python/pascal_voc_xml2json/pascal_voc_xml2json.py @@ -143,7 +143,7 @@ def parseXmlFiles(xml_path): if current_sub == 'bndbox': if bndbox[option.tag] is not None: raise Exception('xml structure corrupted at bndbox tag.') - bndbox[option.tag] = int(option.text) + bndbox[option.tag] = float(option.text) #only after parse the tag if bndbox['xmin'] is not None: @@ -166,7 +166,8 @@ def parseXmlFiles(xml_path): addAnnoItem(object_name, current_image_id, current_category_id, bbox ) if __name__ == '__main__': - xml_path = 'Annotations' - json_file = 'instances.json' +# xml_path = 'Annotations' + xml_path ="D:\\ROCSAFE\\Datasets\\annotations\\Test_v1_7_classes-PascalVOC-export\\Annotations" + json_file = 'instances_val_2.json' parseXmlFiles(xml_path) json.dump(coco, open(json_file, 'w')) \ No newline at end of file