-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
68 lines (47 loc) · 1.89 KB
/
main.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
import argparse
import torch
import os
from slam import SLAM
from dfvo.libs.general.configuration import ConfigLoader
config_loader = ConfigLoader()
def read_cfgs():
"""Parse arguments and laod configurations
Returns
-------
args : args
arguments
cfg : edict
configuration dictionary
"""
''' Argument Parsing '''
parser = argparse.ArgumentParser(description='SLAM system')
parser.add_argument("-d", "--default_configuration", type=str,
default="cfg/default.yml",
help="default configuration files")
parser.add_argument("-c", "--configuration", type=str,
default=None,
help="custom configuration file")
parser.add_argument("-r", "--data_root", type=str, default="./data",
help="path containing image sequence directory")
parser.add_argument("-s", "--seq", type=str, default="09",
help="which (kitti) image sequence to perform VO on")
parser.add_argument("-e", "--ext", type=str, default="png",
help="file extension of the images")
args = parser.parse_args()
''' Read configuration '''
# read default and custom config, merge cfgs
config_files = [args.default_configuration, args.configuration]
cfg = config_loader.merge_cfg(config_files)
return args, cfg
if __name__ == '__main__':
# Read config
args, cfg = read_cfgs()
# use images in the "image_2" folder for VO
img_dir = os.path.join(args.data_root, args.seq, 'image_2')
# folder path that contains the calibration file
calib_dir = os.path.join(args.data_root, args.seq)
# use CUDA
device = torch.device("cuda")
""" perform VO """
slam = SLAM(img_dir, calib_dir, cfg, device)
slam.main()