-
Notifications
You must be signed in to change notification settings - Fork 1
/
collect_data.py
67 lines (49 loc) · 1.8 KB
/
collect_data.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
# Basically
# This is the idea
# On button 1 press - start data collection (stream camera to file + stream radar to file)
# On button 2 press - stop data collection
# pseudocode
# on launch
# open serial interface + open camera interface in TWO separate threads
# BUT do NOT start recording
# on gpio rising edge:
# start serial recording
# in this thread we: read serial, convert to CSV
# start camera recording
# in this thread we: read camera frame, store frame locally
# what we need:
# Serial Reader class: launch/open_serial() | process_frame() | close_serial()
# save_frame()
# Camera Reader class: launch/open_camera() | process_frame() | close_camera()
# save_frame()
import signal
import time
from SerialReader import SerialReader
from CameraReader import CameraReader
def interrupt_handler(sig, frame):
global kill
kill = True
stop_watching()
def stop_watching():
camera.stop()
serial.stop()
def start_watching():
global kill
camera.start()
serial.start()
while not kill:
time.sleep(0.5)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Run the data collection pipeline')
parser.add_help = True
parser.add_argument('--control_port', help='COM port for configuration, control')
parser.add_argument('--data_port', help='COM port for radar data transfer')
parser.add_argument('--output_name', help='Name of the output collection of files')
parser.add_argument('--prof', help='Radar Chirp profile to use')
args = parser.parse_args()
kill = False
signal.signal(signal.SIGINT, interrupt_handler)
camera = CameraReader(args.output_name + '.mp4')
serial = SerialReader(args.output_name + '.csv', args.control_port, args.data_port)
start_watching()