code: def parse_single_file(path, difficult, img_reshape):
      tree = et.parse(path)
      root = tree.getroot()
      d = etree_to_dict(root)
      trimmed = d["annotation"]
      olist = trimmed["object"]
      if not isinstance(olist, collections.Sequence):
          trimmed["object"] = [olist]
          olist = trimmed["object"]
      size = trimmed["size"]
  
      # Add version number to json
      trimmed["version"] = {"major": 1, "minor": 0}
  
      if img_reshape is not None:
          assert len(img_reshape) == 2
          scale = [None, None]
          scale[0] = float(img_reshape[0]) / float(size["height"])
          scale[1] = float(img_reshape[1]) / float(size["width"])
          size["width"] = int(img_reshape[1])
          size["height"] = int(img_reshape[0])
      else:
          scale = [1.0, 1.0]
          size["width"] = int(size["width"])
          size["height"] = int(size["height"])
  
      # convert all numbers from string representation to number so json does not quote them
      # all of the bounding box numbers are one based so subtract 1
      size["depth"] = int(size["depth"])
      width = trimmed["size"]["width"]
      height = trimmed["size"]["height"]
      for obj in olist:
          obj["difficult"] = int(obj["difficult"]) != 0
          obj["truncated"] = int(obj["truncated"]) != 0
          box = obj["bndbox"]
          box["xmax"] = int((float(box["xmax"]) - 1) * scale[1])
          box["xmin"] = int((float(box["xmin"]) - 1) * scale[1])
          box["ymax"] = int((float(box["ymax"]) - 1) * scale[0])
          box["ymin"] = int((float(box["ymin"]) - 1) * scale[0])
          if "part" in obj:
              for part in obj["part"]:
                  box = part["bndbox"]
                  box["xmax"] = int((float(box["xmax"]) - 1) * scale[1])
                  box["xmin"] = int((float(box["xmin"]) - 1) * scale[1])
                  box["ymax"] = int((float(box["ymax"]) - 1) * scale[0])
                  box["ymin"] = int((float(box["ymin"]) - 1) * scale[0])
          xmax = box["xmax"]
          xmin = box["xmin"]
          ymax = box["ymax"]
          ymin = box["ymin"]
          if xmax > width - 1:
              print("xmax {0} exceeds width {1}").format(xmax, width)
          if xmin < 0:
              print("xmin {0} exceeds width {1}").format(xmin, width)
          if ymax > height - 1:
              print("ymax {0} exceeds width {1}").format(ymax, height)
          if ymin < 0:
              print("ymin {0} exceeds width {1}").format(ymin, height)
  
      # exclude difficult objects
      if not difficult:
          trimmed["object"] = [
              o for o in trimmed["object"] if not o["difficult"]
          ]
  
      return trimmed
  
file_path: neon/examples/ssd/datasets/convert_xml_to_json.py
imports: import json
  import glob
  import collections
  import os
  from os.path import join
  import xml.etree.ElementTree
  from collections import defaultdict
  import argparse
label_desc: Use image node_id 5 for calling a global function with example usage: parse_single_file(path, difficult, img_reshape) and returns: trimmed