-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathcreate_data_sym_links.py
85 lines (53 loc) · 2.31 KB
/
create_data_sym_links.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
81
82
83
84
85
import os
data_dir = 'data'
left_image_dir = 'image_2'
right_image_dir = 'image_3'
# train_sequences = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
# '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']
train_sequences = ['05', '12']
test_sequences = ['10']
train_dir = os.path.join(data_dir, 'train')
test_dir = os.path.join(data_dir, 'test')
if not os.path.exists(train_dir):
os.makedirs(train_dir)
if not os.path.exists(test_dir):
os.makedirs(test_dir)
if not os.path.exists(os.path.join(train_dir, 'left')):
os.makedirs(os.path.join(train_dir, 'left'))
if not os.path.exists(os.path.join(train_dir, 'right')):
os.makedirs(os.path.join(train_dir, 'right'))
if not os.path.exists(os.path.join(test_dir, 'left')):
os.makedirs(os.path.join(test_dir, 'left'))
if not os.path.exists(os.path.join(test_dir, 'right')):
os.makedirs(os.path.join(test_dir, 'right'))
root_dir = os.getcwd()
for seq in train_sequences:
l_dir = os.path.join(data_dir, 'dataset', 'sequences', seq, left_image_dir)
r_dir = os.path.join(data_dir, 'dataset', 'sequences', seq, right_image_dir)
for (_, _, left_filenames) in os.walk(l_dir):
break
for (_, _, right_filenames) in os.walk(r_dir):
break
for file in left_filenames:
src_path = os.path.join(root_dir, l_dir, file)
dst_path = os.path.join(train_dir, 'left', seq+file)
os.symlink(src_path, dst_path)
for file in right_filenames:
src_path = os.path.join(root_dir, r_dir, file)
dst_path = os.path.join(train_dir, 'right', seq+file)
os.symlink(src_path, dst_path)
for seq in test_sequences:
l_dir = os.path.join(data_dir, 'dataset', 'sequences', seq, left_image_dir)
r_dir = os.path.join(data_dir, 'dataset', 'sequences', seq, right_image_dir)
for (_, _, left_filenames) in os.walk(l_dir):
break
for (_, _, right_filenames) in os.walk(r_dir):
break
for file in left_filenames:
src_path = os.path.join(root_dir, l_dir, file)
dst_path = os.path.join(test_dir, 'left', seq+file)
os.symlink(src_path, dst_path)
for file in right_filenames:
src_path = os.path.join(root_dir, r_dir, file)
dst_path = os.path.join(test_dir, 'right', seq+file)
os.symlink(src_path, dst_path)