-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaav.py
More file actions
151 lines (114 loc) · 3.79 KB
/
Copy pathaav.py
File metadata and controls
151 lines (114 loc) · 3.79 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import cv2
import time
import warg
from neodroid.utilities.environment_interface.neodroid_camera import extract_neodroid_camera_images
__author__ = 'cnheider'
# import cv2
import matplotlib.pyplot as plt
from matplotlib import animation
from neodroid.wrappers.gym_wrapper import NeodroidVectorGymWrapper as neogym
def grab_video_frame(cap):
ret, frame = cap.read()
return cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_i = 0
time_s = time.time()
image_axs = warg.NOD()
env = neogym(environment_name='aav', connect_to_running=False)
fig = plt.figure()
def update_figures(i):
global time_s, frame_i, image_axs
sample = env.action_space.sample()
obs, signal, terminated, info = env.step(sample)
print(obs)
images = extract_neodroid_camera_images(env)
time_now = time.time()
if time_s:
fps = (1 / (time_now - time_s))
else:
fps = 0
time_s = time_now
fig.suptitle(f'Update{i}, '
f'Frame: {frame_i}, '
f'FPS: {fps}, '
f'Signal: {signal}, '
f'Terminated: {bool(terminated)}')
if image_axs.rgb_image:
image_axs.rgb_image.set_data(images.rgb_image)
if image_axs.depth_image:
image_axs.depth_image.set_data(images.depth_image)
if image_axs.infrared_image:
image_axs.infrared_image.set_data(images.infrared_image)
if image_axs.flow_image:
image_axs.flow_image.set_data(images.flow_image)
if image_axs.normal_image:
image_axs.normal_image.set_data(images.normal_image)
if image_axs.satellite_image:
image_axs.satellite_image.set_data(images.satellite_image)
if image_axs.object_space_image:
image_axs.object_space_image.set_data(images.object_space_image)
if image_axs.uvs_image:
image_axs.uvs_image.set_data(images.uvs_image)
if image_axs.tangents_image:
image_axs.tangents_image.set_data(images.tangents_image)
if terminated:
env.reset()
frame_i = 0
else:
frame_i += 1
def main():
global image_axs
((rgb_image,
depth_image,
infrared_image),
(flow_image,
normal_image,
satellite_image),
(object_space_image,
uvs_image,
tangents_image)) = fig.subplots(3, 3, sharey='all')
image_axs = warg.NOD.dict_of(rgb_image,
depth_image,
infrared_image,
flow_image,
normal_image,
satellite_image,
object_space_image,
uvs_image,
tangents_image)
env.reset()
obs, rew, term, info = env.step(env.action_space.sample())
print(obs)
images = extract_neodroid_camera_images(env)
rgb_image.set_title('RGB')
if images.rgb_image:
image_axs.rgb_image = rgb_image.imshow(images.rgb_image)
depth_image.set_title('Depth')
if images.depth_image:
image_axs.depth_image = depth_image.imshow(images.depth_image)
infrared_image.set_title('Infrared')
if images.infrared_image:
image_axs.infrared_image = infrared_image.imshow(images.infrared_image)
flow_image.set_title('Flow')
if images.flow_image:
image_axs.flow_image = flow_image.imshow(images.flow_image)
normal_image.set_title('Normal')
if images.normal_image:
image_axs.normal_image = normal_image.imshow(images.normal_image)
satellite_image.set_title('Satellite')
if images.satellite_image:
image_axs.satellite_image = satellite_image.imshow(images.satellite_image)
object_space_image.set_title('object_space_image')
if images.object_space_image:
image_axs.object_space_image = object_space_image.imshow(images.object_space_image)
uvs_image.set_title('uvs_image')
if images.uvs_image:
image_axs.uvs_image = uvs_image.imshow(images.uvs_image)
tangents_image.set_title('tangents_image')
if images.tangents_image:
image_axs.tangents_image = tangents_image.imshow(images.tangents_image)
_ = animation.FuncAnimation(fig, update_figures)
plt.show()
if __name__ == '__main__':
main()