# Path: object_detection/vod_converter/converter.py
# class Ingestor:
#     def validate(self, path):
#         """
#         Validate that a path contains files / directories expected for a given data format.
# 
#         This is where you can provide feedback to the end user if they are attempting to convert from
#         your format but have passed you path to a directory that is missing the expected files or directory
#         structure.
# 
#         :param path: Where the data is stored
#         :return: (sucess, error message), e.g (False, "error message") if anything is awry, (True, None) otherwise.
#         """
#         return True, None
# 
#     def ingest(self, path):
#         """
#         Read in data from the filesytem.
#         :param path: '/path/to/data/'
#         :return: an array of dicts conforming to `IMAGE_DETECTION_SCHEMA`
#         """
#         pass
# 
# class Egestor:
# 
#     def expected_labels(self):
#         """
#         Return a dict with a key for each label generally expected by this dataset format and
#         any aliases that should be converted.
# 
#         In the example below the expected labels are 'car' and 'pedestrian' and, for example, both
#         'Car' and 'auto' should be converted to 'car'.
# 
#         :return: {'car': ['Car', 'auto'], 'pedestrian': ['Person']}
#         """
#         raise NotImplementedError()
# 
#     def egest(self, image_detections, root):
#         """
#         Output data to the filesystem.
# 
#         Note: image_detections will already have any conversions specified via `expected_labels` applied
#         by the time they are passed to this method.
# 
#         :param image_detections: an array of dicts conforming to `IMAGE_DETECTION_SCHEMA`
#         :param root: '/path/to/output/data/'
#         """
#         raise NotImplementedError()


import csv
import errno
import os
import shutil
from PIL import Image
from object_detection.vod_converter.converter import Ingestor, Egestor

#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.


"""




def pad_with_zeroes(img_id):
    return "%06d" % (int(img_id),)



# Path: object_detection/vod_converter/converter.py
# class Ingestor:
#     def validate(self, path):
#         """
#         Validate that a path contains files / directories expected for a given data format.
# 
#         This is where you can provide feedback to the end user if they are attempting to convert from
#         your format but have passed you path to a directory that is missing the expected files or directory
#         structure.
# 
#         :param path: Where the data is stored
#         :return: (sucess, error message), e.g (False, "error message") if anything is awry, (True, None) otherwise.
#         """
#         return True, None
# 
#     def ingest(self, path):
#         """
#         Read in data from the filesytem.
#         :param path: '/path/to/data/'
#         :return: an array of dicts conforming to `IMAGE_DETECTION_SCHEMA`
#         """
#         pass
# 
# class Egestor:
# 
#     def expected_labels(self):
#         """
#         Return a dict with a key for each label generally expected by this dataset format and
#         any aliases that should be converted.
# 
#         In the example below the expected labels are 'car' and 'pedestrian' and, for example, both
#         'Car' and 'auto' should be converted to 'car'.
# 
#         :return: {'car': ['Car', 'auto'], 'pedestrian': ['Person']}
#         """
#         raise NotImplementedError()
# 
#     def egest(self, image_detections, root):
#         """
#         Output data to the filesystem.
# 
#         Note: image_detections will already have any conversions specified via `expected_labels` applied
#         by the time they are passed to this method.
# 
#         :param image_detections: an array of dicts conforming to `IMAGE_DETECTION_SCHEMA`
#         :param root: '/path/to/output/data/'
#         """
#         raise NotImplementedError()


# Path: object_detection/vod_converter/kitti.py
import csv
import errno
import os
import shutil
from PIL import Image
from object_detection.vod_converter.converter import Ingestor, Egestor


#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.


"""




def pad_with_zeroes(img_id):
    return "%06d" % (int(img_id),)



class KITTIIngestor(Ingestor):