-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd.py
More file actions
48 lines (39 loc) · 1.42 KB
/
Copy pathcmd.py
File metadata and controls
48 lines (39 loc) · 1.42 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
47
48
import argparse
PORT = 4242
YPR_PORT = 9000
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="localhost",
help="udp server hostname")
parser.add_argument("-p", "--port", type=int, default=4242,
help="udp server port")
parser.add_argument("-v", "--video", action="store_true",
help="show a live video preview of the tracking results")
parser.add_argument("--verbose", action="store_true",
help="enable verbose ouput")
parser.add_argument("-c", "--client", choices=["udp", "osc", "ypr"], required=True,
help="choose client implementation")
args = parser.parse_args()
from facemesh_tracker import FaceMeshTracker
from facemesh_preview import FaceMeshPreview
if args.client == "udp":
from client.udp import UDPServer
ClientImplementation = UDPServer
elif args.client in ["osc", "ypr"]:
from client.osc import OSCServer
ClientImplementation = OSCServer
# set default YPR port
if args.client == "ypr" and args.port == PORT:
args.port = YPR_PORT
server = ClientImplementation(args.host, args.port, args.client)
print("INFO: Sending tracking data to {}:{} via {}".format(args.host, args.port, args.client))
if args.video:
preview = FaceMeshPreview()
else:
preview = None
with FaceMeshTracker(server, preview) as tracker:
try:
print("INFO: Tracker is starting")
tracker.start()
except KeyboardInterrupt:
pass
print("INFO: Closing tracker.")