-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprepare_KITTI_DC.py.py
80 lines (59 loc) · 2.67 KB
/
prepare_KITTI_DC.py.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
import sys
import shutil
import argparse
parser = argparse.ArgumentParser(
description="KITTI Depth Completion dataset preparer")
parser.add_argument('--path_root_dc', type=str, required=True,
help="Path to the Depth completion dataset")
parser.add_argument('--path_root_raw', type=str, required=True,
help="Path to the Raw dataset")
args = parser.parse_args()
def check_dir_existence(path_dir):
assert os.path.isdir(path_dir), \
"Directory does not exist : {}".format(path_dir)
def check_file_existence(path_file):
assert os.path.isfile(path_file), \
"File does not exist : {}".format(path_file)
def prepare_reorganization():
check_dir_existence(args.path_root_dc)
check_dir_existence(args.path_root_raw)
print("Preparation of reorganization is done.")
def reorganize_train_val():
for split in ['train', 'val']:
path_dc = args.path_root_dc + '/' + split
check_dir_existence(path_dc)
list_seq = os.listdir(path_dc)
list_seq.sort()
for seq in list_seq:
path_raw_seq_src = args.path_root_raw + '/' + seq[0:10] + '/' + seq
path_seq_dst = path_dc + '/' + seq
try:
print("Copying raw dataset : {} -> {}".format(
path_raw_seq_src + '/image_02', path_seq_dst + '/image_02'))
shutil.copytree(path_raw_seq_src + '/image_02',
path_seq_dst + '/image_02')
print("Copying raw dataset : {} -> {}".format(
path_raw_seq_src + '/image_03', path_seq_dst + '/image_03'))
shutil.copytree(path_raw_seq_src + '/image_03',
path_seq_dst + '/image_03')
print("Copying raw dataset : {} -> {}".format(
path_raw_seq_src + '/oxts', path_seq_dst + '/oxts'))
shutil.copytree(path_raw_seq_src + '/oxts',
path_seq_dst + '/oxts')
for calib in ['calib_cam_to_cam.txt',
'calib_imu_to_velo.txt',
'calib_velo_to_cam.txt']:
shutil.copy2(args.path_root_raw + '/' + seq[0:10] + '/'
+ calib, path_seq_dst + '/' + calib)
except OSError:
print("Failed to copy files for {}".format(seq))
sys.exit(-1)
print("Reorganization for {} split finished".format(split))
if __name__ == '__main__':
print('\nArguments :')
for arg in vars(args):
print(arg, ':', getattr(args, arg))
print('')
prepare_reorganization()
reorganize_train_val()