code: def convert_annot_to_json(path, im_path, out_path, difficult):
      """
      Converts the KITTI annotations to json file.
  
      Uses the below reference for the KITTI dataset:
  
      OO representation of label format used in Kitti dataset.
  
      Description of fields from Kitti dataset dev kit: (link)[]
      The label files contain the following information, which can be read and
      written using the matlab tools (readLabels.m, writeLabels.m) provided within
      this devkit. All values (numerical or strings) are separated via spaces,
      each row corresponds to one object. The 15 columns represent:
      #Values    Name      Description
      ----------------------------------------------------------------------------
         1    type         Describes the type of object: 'Car', 'Van', 'Truck',
                           'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram',
                           'Misc' or 'DontCare'
         1    truncated    Float from 0 (non-truncated) to 1 (truncated), where
                           truncated refers to the object leaving image boundaries
         1    occluded     Integer (0,1,2,3) indicating occlusion state:
                           0 = fully visible, 1 = partly occluded
                           2 = largely occluded, 3 = unknown
         1    alpha        Observation angle of object, ranging [-pi..pi]
         4    bbox         2D bounding box of object in the image (0-based index):
                           contains left, top, right, bottom pixel coordinates
         3    dimensions   3D object dimensions: height, width, length (in meters)
         3    location     3D object location x,y,z in camera coordinates (in meters)
         1    rotation_y   Rotation ry around Y-axis in camera coordinates [-pi..pi]
         1    score        Only for results: Float, indicating confidence in
                           detection, needed for p/r curves, higher is better.
  
      Arguments:
          path (string): path to KITTI annotation file
          im_path (string): path to image
          out_path (string): path to save the json file
          difficult (bool): include difficult objects
      """
      with open(path) as f:
          labels = f.readlines()
  
      # start empty dictionary
      annot = {"object": []}
  
      # load image
      im = np.array(Image.open(im_path))
      (h, w, c) = im.shape
      annot["size"] = {"depth": c, "height": h, "width": w}
  
      for label in labels:
          vals = label.split()
          type = vals[0]
          truncated = float(vals[1])
          occluded = int(vals[2])
          bbox = tuple([float(x) for x in vals[4:8]])
          bbox_int = tuple([int(math.floor(x)) for x in bbox])
  
          if type == "DontCare":
              assert truncated == -1
              assert occluded == -1
          else:
              assert occluded in (0, 1, 2, 3)
  
          diff = truncated > 0.5 or occluded == 2
  
          # add object to annotation
          obj = {
              "bndbox": {
                  "xmin": bbox_int[0],
                  "ymin": bbox_int[1],
                  "xmax": bbox_int[2],
                  "ymax": bbox_int[3],
              },
              "difficult": difficult,
              "name": type,
              "truncated": truncated > 0.5,
              "occluded": occluded,
          }
  
          if not diff or difficult:
              annot["object"].append(obj)
  
      # print "Saving to {}".format(out_path)
  
      with open(out_path, "w") as f:
          json.dump(annot, f, indent=4)
  
file_path: neon/examples/faster-rcnn/ingest_kitti.py
imports: from __future__ import print_function
  import os
  import glob
  import json
  import numpy
  from PIL import Image
  from zipfile import ZipFile
  import math
  from neon.util.persist import ensure_dirs_exist
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: convert_annot_to_json(path, im_path, out_path, difficult) without return types