-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_streamer.py
56 lines (47 loc) · 1.56 KB
/
file_streamer.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
#!/usr/bin/python
import cv2
import argparse
import os
import os.path
import time
from vision_processing import Vision
from networktables import NetworkTable
from data_logger import DataLogger
def find_roborio():
possible_hosts = ["roborio-3223-frc.local","roborio-3223-frc","roborio-3223-frc.frc-robot.local","roborio-3223-frc.frc-robot"]
for host in possible_hosts:
response = os.system("ping -c 1 " + host)
if response == 0:
return host
return possible_hosts[0]
def setup_options_parser():
parser = argparse.ArgumentParser(description='read structure sensor data.')
parser.add_argument(
'--log-dir', dest='log_dir', metavar='LDIR',
default='/opt/data',
help='specify directory in which to log data')
parser.add_argument(
'--output-dir', metavar='ODIR',
default='/opt/',
help='specify directory in which to deposit structure.jpg')
return parser
parser = setup_options_parser()
args = parser.parse_args()
NetworkTable.setIPAddress("10.32.23.2")
NetworkTable.setClientMode()
NetworkTable.initialize()
file_name = os.path.join(args.output_dir, "structure.jpg")
tmp_name = os.path.join(args.output_dir, "structure.tmp.jpg")
vision = Vision()
vision.set_mode(8)
vision.setup_mode_listener()
logger = DataLogger(args.log_dir)
now = time.time()
with vision:
while True:
vision.get_depths()
vision.process_depths()
cv2.imwrite(tmp_name, vision.display)
os.rename(tmp_name, file_name)
logger.log_data(vision.depth, vision.ir)
#time.sleep(0.05)