forked from mileyan/AnyNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolyviewer.py
84 lines (54 loc) · 1.66 KB
/
polyviewer.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
import yaml
with open("config.yml", "r") as config_file:
cfg = yaml.safe_load(config_file)
host = cfg["host"]
port = cfg["port"]
debug = cfg["debug"]
sources = cfg["sources"]
path = cfg["path"]
is_remote = cfg["remote"]
with open("rovercamera/config/stereo.yml", "r") as rovercamera_config_file:
rovercamera_cfg = yaml.unsafe_load(rovercamera_config_file)
import rovercamera
import cv2 as cv
import logging
import uuid
import os
# urllib debug messages
if debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
def get_rovercamera(name):
# logging.info("Connecting to: ", name)
print(rovercamera_cfg)
return rovercamera.RoverCamera(name, config=rovercamera_cfg)
logging.info("Host: ", host, " port: ", port)
cameras = []
for source in sources:
cameras.append(get_rovercamera(source))
dataset_path = path + str(uuid.uuid4())
os.mkdir(dataset_path)
for i in range(len(cameras)):
print(dataset_path + "/" + str(i))
os.mkdir(dataset_path + "/" + str(i))
logging.info("Created dataset: " + dataset_path)
count = 0
while True:
count += 1
# Fetch images
logging.info("Fetching images")
images = []
for camera in cameras:
images.append(camera.get_frame())
preview_images = []
for image in images:
preview_images.append(cv.resize(image, (360, 240)))
preview = cv.vconcat(preview_images)
# Show
cv.imshow("Preview", preview)
if cv.waitKey(1) == ord('s'):
for j in range(len(cameras)):
cv.imwrite(dataset_path + "/" + str(j) +
"/" + str(count) + ".jpg", images[j])
logging.info("Saved! ")