-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathdemo2.py
46 lines (36 loc) · 1.96 KB
/
demo2.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
import os
import glob
import matplotlib as plt
from util.camera_pose_visualizer import CameraPoseVisualizer
from util.camera_parameter_loader import CameraParameterLoader
def plot_scenewise():
loader = CameraParameterLoader()
visualizer = CameraPoseVisualizer([-50, 50], [-50, 50], [0, 100])
list_scene = list(filter(os.path.isdir, glob.glob(os.path.join('dataset', '*', 'trajectory'))))
for idx_scene, scene in enumerate(list_scene):
list_frame_annotation = glob.glob(os.path.join(scene, '[0-9][0-9][0-9][0-9][0-9][0-9].json'))
for idx_frame, frame_annotation in enumerate(list_frame_annotation):
if idx_frame % 10 == 0:
extrinsic = loader.get_extrinsic(frame_annotation)
visualizer.extrinsic2pyramid(extrinsic, plt.cm.rainbow(idx_scene / len(list_scene)), 10)
list_scene = [os.path.split(os.path.split(i)[0])[-1] for i in list_scene]
visualizer.customize_legend(list_scene)
visualizer.show()
def plot_framewise():
loader = CameraParameterLoader()
visualizer = CameraPoseVisualizer([-50, 50], [-50, 50], [0, 100])
list_scene = list(filter(os.path.isdir, glob.glob(os.path.join('dataset', '*', 'trajectory'))))
max_frame_length = 0
for idx_scene, scene in enumerate(list_scene):
list_frame_annotation = glob.glob(os.path.join(scene, '[0-9][0-9][0-9][0-9][0-9][0-9].json'))
max_frame_length = max(max_frame_length, len(list_frame_annotation))
for idx_scene, scene in enumerate(list_scene):
list_frame_annotation = glob.glob(os.path.join(scene, '[0-9][0-9][0-9][0-9][0-9][0-9].json'))
for idx_frame, frame_annotation in enumerate(list_frame_annotation):
if idx_frame % 10 == 0:
extrinsic = loader.get_extrinsic(frame_annotation)
visualizer.extrinsic2pyramid(extrinsic, plt.cm.rainbow(idx_frame / max_frame_length), 10)
visualizer.colorbar(max_frame_length)
visualizer.show()
plot_scenewise()
plot_framewise()