class_docstr: Generate data for a KITTI dataset.
  
  See http://www.cvlibs.net/datasets/kitti/ for more information.
class_docstr_tok: ["Generate","data","for","a","KITTI","dataset",".","See","http",":","\/\/www.cvlibs.net\/datasets\/kitti\/","for","more","information","."]
docstr: Initialize a KITTI data generator.
  
  Args
      base_dir: Directory w.r.t. where the files are to be searched (defaults to the directory containing the csv_data_file).
      subset: The subset to generate data for (defaults to 'train').
docstr_tok: ["Initialize","a","KITTI","data","generator",".","Args","base_dir",":","Directory","w.r.t",".","where","the","files","are","to","be","searched","(","defaults","to","the","directory","containing","the","csv_data_file",")",".","subset",":","The","subset","to","generate","data","for","(","defaults","to","'train","'",")","."]
code: def __init__(self, base_dir, subset="train", **kwargs):
      """Initialize a KITTI data generator.
  
      Args
          base_dir: Directory w.r.t. where the files are to be searched (defaults to the directory containing the csv_data_file).
          subset: The subset to generate data for (defaults to 'train').
      """
      self.base_dir = base_dir
  
      label_dir = os.path.join(self.base_dir, subset, "labels")
      image_dir = os.path.join(self.base_dir, subset, "images")
  
      """
          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]
          """
  
      self.labels = {}
      self.classes = kitti_classes
      for name, label in self.classes.items():
          self.labels[label] = name
  
      self.image_data = dict()
      self.images = []
      for i, fn in enumerate(os.listdir(label_dir)):
          label_fp = os.path.join(label_dir, fn)
          image_fp = os.path.join(image_dir, fn.replace(".txt", ".png"))
  
          self.images.append(image_fp)
  
          fieldnames = [
              "type",
              "truncated",
              "occluded",
              "alpha",
              "left",
              "top",
              "right",
              "bottom",
              "dh",
              "dw",
              "dl",
              "lx",
              "ly",
              "lz",
              "ry",
          ]
          with open(label_fp, "r") as csv_file:
              reader = csv.DictReader(
                  csv_file, delimiter=" ", fieldnames=fieldnames
              )
              boxes = []
              for line, row in enumerate(reader):
                  label = row["type"]
                  cls_id = kitti_classes[label]
  
                  annotation = {
                      "cls_id": cls_id,
                      "x1": row["left"],
                      "x2": row["right"],
                      "y2": row["bottom"],
                      "y1": row["top"],
                  }
                  boxes.append(annotation)
  
              self.image_data[i] = boxes
  
      super(KittiGenerator, self).__init__(**kwargs)
  
file_path: ImageAI/imageai_tf_deprecated/Detection/keras_retinanet/preprocessing/kitti.py
imports: import csv
  import os.path
  import numpy
  from PIL import Image
  from .generator import Generator
  from ..utils.image import read_image_bgr
label_desc: Use image node_id 1 to create a new KittiGenerator object from inherited base classes: Generator with example: obj = KittiGenerator(base_dir, subset)