# Path: piecewisecrf/datasets/kitti/kitti.py
# class KittiDataset(Dataset):
#     '''
# 
#     Kitti dataset abstraction
# 
#     '''
#     def __init__(self, train_dir=None, val_dir=None, test_dir=None):
#         super(KittiDataset, self).__init__(train_dir, val_dir, test_dir)
# 
#         self.labels = [
#             # name id trainId category catId hasInstances ignoreInEval color
#             Label('sky', 0, 0, 'void', 0, False, False, (128, 128, 128)),
#             Label('building', 1, 1, 'void', 0, False, False, (128, 0, 0)),
#             Label('road', 2, 2, 'void', 0, False, False, (128, 64, 128)),
#             Label('sidewalk', 3, 3, 'void', 0, False, False, (0, 0, 192)),
#             Label('fence', 4, 4, 'void', 0, False, False, (64, 64, 128)),
#             Label('vegetation', 5, 5, 'void', 0, False, False, (128, 128, 0)),
#             Label('pole', 6, 6, 'void', 0, False, False, (192, 192, 128)),
#             Label('car', 7, 7, 'void', 0, False, False, (64, 0, 128)),
#             Label('sign', 8, 8, 'void', 0, False, False, (192, 128, 128)),
#             Label('pedestrian', 9, 9, 'void', 0, False, False, (64, 64, 0)),
#             Label('cyclist', 10, 10, 'void', 0, False, False, (0, 128, 192)),
#             Label('ignore', 11, 11, 'void', 0, False, True, (0, 0, 0)),
#         ]
# 
#         self.classes = list(range(11))
# 
#         self.create_collections()


import argparse
import os
import tqdm
import skimage
import skimage.data
import skimage.transform
import numpy as np
import piecewisecrf.helpers.io as io
from piecewisecrf.datasets.kitti.kitti import KittiDataset
    label_input_dir = os.path.join(subset_dir, 'labels')
    output_dir = _create_folder(output_dir, subset)

    # create folder hierarchy for original size images
    if not onlyresize:
        (label_dest_dir, image_dest_dir, image_dest_ppm_dir,
            label_dest_ppm_dir, label_dest_bin_dir) = _create_folders(output_dir, 'original')

    # create folder hierarchy for the resized images
    if resize:
        (label_dest_dir_resized, image_dest_dir_resized,
            image_dest_ppm_dir_resized, label_dest_ppm_dir_resized,
            label_dest_bin_dir_resized) = _create_folders(output_dir, '{}x{}'.format(resize[0], resize[1]))
    print("Finished creating directories")

    print("Creating image files")
    for file_name in tqdm.tqdm(os.listdir(image_input_dir)):
        img = skimage.data.load(os.path.join(image_input_dir, file_name))
        file_prefix = file_name[0:file_name.index('.')]

        if not onlyresize:
            skimage.io.imsave(os.path.join(image_dest_dir, '{}.png'.format(file_prefix)), img)
            skimage.io.imsave(os.path.join(image_dest_ppm_dir, '{}.ppm'.format(file_prefix)), img)

        if resize:
            img = skimage.transform.resize(img, (resize[1], resize[0]), order=3)
            skimage.io.imsave(os.path.join(image_dest_dir_resized, '{}.png'.format(file_prefix)), img)
            skimage.io.imsave(os.path.join(image_dest_ppm_dir_resized, '{}.ppm'.format(file_prefix)), img)

    print("Creating label files")

# Path: piecewisecrf/datasets/kitti/kitti.py
# class KittiDataset(Dataset):
#     '''
# 
#     Kitti dataset abstraction
# 
#     '''
#     def __init__(self, train_dir=None, val_dir=None, test_dir=None):
#         super(KittiDataset, self).__init__(train_dir, val_dir, test_dir)
# 
#         self.labels = [
#             # name id trainId category catId hasInstances ignoreInEval color
#             Label('sky', 0, 0, 'void', 0, False, False, (128, 128, 128)),
#             Label('building', 1, 1, 'void', 0, False, False, (128, 0, 0)),
#             Label('road', 2, 2, 'void', 0, False, False, (128, 64, 128)),
#             Label('sidewalk', 3, 3, 'void', 0, False, False, (0, 0, 192)),
#             Label('fence', 4, 4, 'void', 0, False, False, (64, 64, 128)),
#             Label('vegetation', 5, 5, 'void', 0, False, False, (128, 128, 0)),
#             Label('pole', 6, 6, 'void', 0, False, False, (192, 192, 128)),
#             Label('car', 7, 7, 'void', 0, False, False, (64, 0, 128)),
#             Label('sign', 8, 8, 'void', 0, False, False, (192, 128, 128)),
#             Label('pedestrian', 9, 9, 'void', 0, False, False, (64, 64, 0)),
#             Label('cyclist', 10, 10, 'void', 0, False, False, (0, 128, 192)),
#             Label('ignore', 11, 11, 'void', 0, False, True, (0, 0, 0)),
#         ]
# 
#         self.classes = list(range(11))
# 
#         self.create_collections()


# Path: piecewisecrf/datasets/kitti/prepare_dataset_files.py
import argparse
import os
import tqdm
import skimage
import skimage.data
import skimage.transform
import numpy as np
import piecewisecrf.helpers.io as io
from piecewisecrf.datasets.kitti.kitti import KittiDataset

    label_input_dir = os.path.join(subset_dir, 'labels')
    output_dir = _create_folder(output_dir, subset)

    # create folder hierarchy for original size images
    if not onlyresize:
        (label_dest_dir, image_dest_dir, image_dest_ppm_dir,
            label_dest_ppm_dir, label_dest_bin_dir) = _create_folders(output_dir, 'original')

    # create folder hierarchy for the resized images
    if resize:
        (label_dest_dir_resized, image_dest_dir_resized,
            image_dest_ppm_dir_resized, label_dest_ppm_dir_resized,
            label_dest_bin_dir_resized) = _create_folders(output_dir, '{}x{}'.format(resize[0], resize[1]))
    print("Finished creating directories")

    print("Creating image files")
    for file_name in tqdm.tqdm(os.listdir(image_input_dir)):
        img = skimage.data.load(os.path.join(image_input_dir, file_name))
        file_prefix = file_name[0:file_name.index('.')]

        if not onlyresize:
            skimage.io.imsave(os.path.join(image_dest_dir, '{}.png'.format(file_prefix)), img)
            skimage.io.imsave(os.path.join(image_dest_ppm_dir, '{}.ppm'.format(file_prefix)), img)

        if resize:
            img = skimage.transform.resize(img, (resize[1], resize[0]), order=3)
            skimage.io.imsave(os.path.join(image_dest_dir_resized, '{}.png'.format(file_prefix)), img)
            skimage.io.imsave(os.path.join(image_dest_ppm_dir_resized, '{}.ppm'.format(file_prefix)), img)

    print("Creating label files")

    dataset = KittiDataset()