-
Notifications
You must be signed in to change notification settings - Fork 143
/
run_slam_pipeline.py
120 lines (106 loc) · 3.87 KB
/
run_slam_pipeline.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""
Main script for UMI SLAM pipeline.
python run_slam_pipeline.py <session_dir>
"""
import sys
import os
ROOT_DIR = os.path.dirname(__file__)
sys.path.append(ROOT_DIR)
os.chdir(ROOT_DIR)
# %%
import pathlib
import click
import subprocess
# %%
@click.command()
@click.argument('session_dir', nargs=-1)
@click.option('-c', '--calibration_dir', type=str, default=None)
def main(session_dir, calibration_dir):
script_dir = pathlib.Path(__file__).parent.joinpath('scripts_slam_pipeline')
if calibration_dir is None:
calibration_dir = pathlib.Path(__file__).parent.joinpath('example', 'calibration')
else:
calibration_dir = pathlib.Path(calibration_dir)
assert calibration_dir.is_dir()
for session in session_dir:
session = pathlib.Path(os.path.expanduser(session)).absolute()
print("############## 00_process_videos #############")
script_path = script_dir.joinpath("00_process_videos.py")
assert script_path.is_file()
cmd = [
'python', str(script_path),
str(session)
]
result = subprocess.run(cmd)
assert result.returncode == 0
print("############# 01_extract_gopro_imu ###########")
script_path = script_dir.joinpath("01_extract_gopro_imu.py")
assert script_path.is_file()
cmd = [
'python', str(script_path),
str(session)
]
result = subprocess.run(cmd)
assert result.returncode == 0
print("############# 02_create_map ###########")
script_path = script_dir.joinpath("02_create_map.py")
assert script_path.is_file()
demo_dir = session.joinpath('demos')
mapping_dir = demo_dir.joinpath('mapping')
assert mapping_dir.is_dir()
map_path = mapping_dir.joinpath('map_atlas.osa')
if not map_path.is_file():
cmd = [
'python', str(script_path),
'--input_dir', str(mapping_dir),
'--map_path', str(map_path)
]
result = subprocess.run(cmd)
assert result.returncode == 0
assert map_path.is_file()
print("############# 03_batch_slam ###########")
script_path = script_dir.joinpath("03_batch_slam.py")
assert script_path.is_file()
cmd = [
'python', str(script_path),
'--input_dir', str(demo_dir),
'--map_path', str(map_path)
]
result = subprocess.run(cmd)
assert result.returncode == 0
print("############# 04_detect_aruco ###########")
script_path = script_dir.joinpath("04_detect_aruco.py")
assert script_path.is_file()
camera_intrinsics = calibration_dir.joinpath('gopro_intrinsics_2_7k.json')
aruco_config = calibration_dir.joinpath('aruco_config.yaml')
assert camera_intrinsics.is_file()
assert aruco_config.is_file()
cmd = [
'python', str(script_path),
'--input_dir', str(demo_dir),
'--camera_intrinsics', str(camera_intrinsics),
'--aruco_yaml', str(aruco_config)
]
result = subprocess.run(cmd)
assert result.returncode == 0
print("############# 05_run_calibrations ###########")
script_path = script_dir.joinpath("05_run_calibrations.py")
assert script_path.is_file()
cmd = [
'python', str(script_path),
str(session)
]
result = subprocess.run(cmd)
assert result.returncode == 0
print("############# 06_generate_dataset_plan ###########")
script_path = script_dir.joinpath("06_generate_dataset_plan.py")
assert script_path.is_file()
cmd = [
'python', str(script_path),
'--input', str(session)
]
result = subprocess.run(cmd)
assert result.returncode == 0
## %%
if __name__ == "__main__":
main()