-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
66 lines (45 loc) · 1.71 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
import cv2
import argparse
import matplotlib.pyplot as plt
from stereoVO.configs import yaml_parser
from stereoVO.datasets import KittiDataset
from stereoVO.utils import SVO_Plot, rmse_error
from stereoVO.model import StereoVO
def parse_argument():
parser = argparse.ArgumentParser()
parser.add_argument('--config_path', default='configs/params.yaml')
return parser.parse_args()
def main():
args = parse_argument()
# Load the config file
params = yaml_parser(args.config_path)
# Get data params using the dataloader
dataset = KittiDataset(params.dataset.path)
num_frames = len(dataset)
cameraMatrix = dataset.intrinsic
projectionMatrixL = dataset.PL
projectionMatrixR = dataset.PR
# Initialise the Plotter module
Plotter = SVO_Plot(figSize=(6, 4))
# Iniitialise the StereoVO model
model = StereoVO(cameraMatrix, projectionMatrixL, projectionMatrixR, params)
# Iterate over the frame and update the rotation and translation vector
for index in range(num_frames):
left_frame, right_frame, ground_pose = dataset[index]
# Do model prediction
pred_location, pred_orientation = model(left_frame, right_frame, index)
# Calculate error
rmse = rmse_error(pred_location, ground_pose[:, -1])
# Plot camera trajectory, frame and error
Plotter.plot_camera_traectories(index, pred_location, pred_orientation, ground_pose)
Plotter.plot_errors(index, rmse)
Plotter.plot_frame(left_frame)
# Clear plot and prepare for next iterations
Plotter.clear()
if index==0:
cv2.waitKey(0)
else:
cv2.waitKey(1)
plt.show()
if __name__ == "__main__":
main()