# Path: object_detection/utils/kitti.py
# def show_groundtruth(image_path):
#     '''Draw bboxes from annotations file on an image'''
#     image = Image.open(image_path)
#     image_np = load_image_into_numpy_array(image)
# 
#     data = get_annotations(image_path)
#     classes = np.array([name_to_id[x['name'].lower()]
#                         for x in data['object']])
#     scores = np.ones(len(data['object']))
#     if classes.ndim != 1:
#         classes = np.squeeze(classes).astype(np.int32)
#     if scores.ndim != 1:
#         scores = np.squeeze(scores).astype(np.int32)
#     box_mat = box_to_matrix(data)
#     visualize_boxes_and_labels_on_image_array(
#         image_np,
#         box_mat,
#         classes,
#         scores,
#         category_index,
#         use_normalized_coordinates=True,
#         line_thickness=8)
#     return image_np
# 
# def get_annotations(image_path):
#     img_id = os.path.basename(image_path)[:-4]
#     annotation_path = os.path.join(
#     os.path.split(os.path.dirname(image_path))[0], 'Annotations',
#     '{}.xml'.format(img_id)
#     )
#     return xml_to_dict(annotation_path)
# 
# Path: object_detection/kitti_to_voc.py
# def kitti_to_voc(from_path, to_path, train_id_path, select_only_known_labels=False,
#                  filter_images_without_labels=False):
#     success, msg = convert(
#         from_path=from_path,
#         ingestor=KITTIIngestor(),
#         to_path=to_path,
#         egestor=VOCEgestor(),
#         select_only_known_labels=select_only_known_labels,
#         filter_images_without_labels=filter_images_without_labels,
#         train_ids=train_id_path)
#     print(msg)


import unittest
from object_detection.utils.kitti import show_groundtruth, get_annotations
from object_detection.kitti_to_voc import kitti_to_voc


IMAGE_PATH = 'kitti_data/training/image_2/2456.jpg'
IMAGE_VOC_PATH= 'voc_kitti/VOC2012/JPEGImages/2456.jpg'
class TestKitti(unittest.TestCase):


    def test_label_retriever(self):
        labels = get_annotations(IMAGE_VOC_PATH)
        print(labels)

# Path: object_detection/utils/kitti.py
# def show_groundtruth(image_path):
#     '''Draw bboxes from annotations file on an image'''
#     image = Image.open(image_path)
#     image_np = load_image_into_numpy_array(image)
# 
#     data = get_annotations(image_path)
#     classes = np.array([name_to_id[x['name'].lower()]
#                         for x in data['object']])
#     scores = np.ones(len(data['object']))
#     if classes.ndim != 1:
#         classes = np.squeeze(classes).astype(np.int32)
#     if scores.ndim != 1:
#         scores = np.squeeze(scores).astype(np.int32)
#     box_mat = box_to_matrix(data)
#     visualize_boxes_and_labels_on_image_array(
#         image_np,
#         box_mat,
#         classes,
#         scores,
#         category_index,
#         use_normalized_coordinates=True,
#         line_thickness=8)
#     return image_np
# 
# def get_annotations(image_path):
#     img_id = os.path.basename(image_path)[:-4]
#     annotation_path = os.path.join(
#     os.path.split(os.path.dirname(image_path))[0], 'Annotations',
#     '{}.xml'.format(img_id)
#     )
#     return xml_to_dict(annotation_path)
# 
# Path: object_detection/kitti_to_voc.py
# def kitti_to_voc(from_path, to_path, train_id_path, select_only_known_labels=False,
#                  filter_images_without_labels=False):
#     success, msg = convert(
#         from_path=from_path,
#         ingestor=KITTIIngestor(),
#         to_path=to_path,
#         egestor=VOCEgestor(),
#         select_only_known_labels=select_only_known_labels,
#         filter_images_without_labels=filter_images_without_labels,
#         train_ids=train_id_path)
#     print(msg)


# Path: object_detection/tests/test_kitti_helpers.py
import unittest
from object_detection.utils.kitti import show_groundtruth, get_annotations
from object_detection.kitti_to_voc import kitti_to_voc



IMAGE_PATH = 'kitti_data/training/image_2/2456.jpg'
IMAGE_VOC_PATH= 'voc_kitti/VOC2012/JPEGImages/2456.jpg'
class TestKitti(unittest.TestCase):


    def test_label_retriever(self):
        labels = get_annotations(IMAGE_VOC_PATH)
        print(labels)

        labeled_image = show_groundtruth(IMAGE_VOC_PATH)