-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.py
More file actions
executable file
·46 lines (36 loc) · 1.45 KB
/
play.py
File metadata and controls
executable file
·46 lines (36 loc) · 1.45 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
#!/usr/bin/env python
from pymocap.manager import Manager
from pymocap.color_terminal import ColorTerminal
from pymocap.readers.natnet_file_reader import NatnetFileReader
from pymocap.writers.osc_writer import OscWriter
from pymocap.writers.natnet_file_writer import NatnetFileWriter
import sys, os
default_file_path = 'walk-198frames.binary.recording'
counter = 0
def onFrame(frame, manager):
global counter
counter += 1
ColorTerminal().blue('Frame count: {0}, frameno: {1}'.format(str(counter), str(frame.frameno)))
# config
file_path = default_file_path if len(sys.argv) < 2 else sys.argv[1]
osc_host = '127.0.0.1' if len(sys.argv) < 3 else sys.argv[2]
osc_port = 8080 if len(sys.argv) < 4 else sys.argv[3]
# initialize all modules
manager = Manager()
manager.frameEvent += onFrame
writer = OscWriter({'host':osc_host, 'port':osc_port, 'manager':manager})
reader = NatnetFileReader({'path': file_path, 'manager': manager, 'autoStart': False})
# uncomment the following line to re-record all frames into a new file
# writer = NatnetFileWriter({'manager': manager})
reader.start()
# 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()