-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.py
More file actions
executable file
·36 lines (29 loc) · 1.21 KB
/
record.py
File metadata and controls
executable file
·36 lines (29 loc) · 1.21 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
#!/usr/bin/env python
from pymocap.manager import Manager
from pymocap.color_terminal import ColorTerminal
from pymocap.readers.natnet_reader import NatnetReader
from pymocap.writers.natnet_file_writer import NatnetFileWriter
import sys
# config
file_path = None if len(sys.argv) < 2 else sys.argv[1]
natnet_host = '0.0.0.0' if len(sys.argv) < 3 else sys.argv[2]
natnet_multicast = '239.255.42.99' if len(sys.argv) < 4 else sys.argv[3]
natnet_port = 1511 if len(sys.argv) < 5 else sys.argv[4]
def onFrameRecorded(natnet_writer):
ColorTerminal().blue('Recorded {0} frames'.format(str(natnet_writer.frameCount)))
# initialize
manager = Manager()
writer = NatnetFileWriter({'path':file_path, 'manager':manager})
reader = NatnetReader(manager=manager, host=natnet_host, multicast=natnet_multicast, port=natnet_port)
writer.frameEvent += onFrameRecorded
# execution loop
while True:
try:
# when the reader receives new data, it will process it and feed it into the manager
# the manager will trigger some events when it gets new data
# the writer will respond to the manager's events and output information
reader.update()
except KeyboardInterrupt:
break
reader.stop()
writer.stop()