-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvision_setfacetracking.py
More file actions
48 lines (35 loc) · 1.48 KB
/
vision_setfacetracking.py
File metadata and controls
48 lines (35 loc) · 1.48 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
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Modify Face Tracking policy on the robot."""
import qi
import argparse
import sys
def main(session):
"""
When tracking is activated, faces looking sideways, or located further away
should be tracked for a longer period.
Launch Monitor, Camera-Viewer, activate face detection, and see if it works better.
"""
tracking_enabled = True
# Get the service ALFaceDetection.
face_service = session.service("ALFaceDetection")
print "Will set tracking to '%s' on the robot ..." % tracking_enabled
# Enable or disable tracking.
face_service.enableTracking(tracking_enabled)
# Just to make sure correct option is set.
print "Is tracking now enabled on the robot?", face_service.isTrackingEnabled()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="192.168.1.5",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)