From 78b8df96b3b807acb368b9e7f077cecddfa86797 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Mon, 17 Oct 2022 11:18:39 +0200 Subject: Using auto discovery tobii on network by default. --- setup.py | 2 +- src/argaze/TobiiGlassesPro2/TobiiController.py | 4 ++-- src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py | 15 +++++---------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index a85b54d..e7ac240 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( packages=find_packages(where='src'), python_requires='>=3.6, <4', - install_requires=['opencv-python==4.6.0.66', 'opencv-contrib-python==4.6.0.66', 'numpy', 'av', 'rtsp', 'pandas', 'matplotlib', 'shapely'], + install_requires=['opencv-python==4.6.0.66', 'opencv-contrib-python==4.6.0.66', 'numpy', 'av', 'rtsp', 'netifaces', 'pandas', 'matplotlib', 'shapely'], project_urls={ 'Bug Reports': 'https://git.recherche.enac.fr/projects/argaze/issues', diff --git a/src/argaze/TobiiGlassesPro2/TobiiController.py b/src/argaze/TobiiGlassesPro2/TobiiController.py index d61d6ab..49e0834 100644 --- a/src/argaze/TobiiGlassesPro2/TobiiController.py +++ b/src/argaze/TobiiGlassesPro2/TobiiController.py @@ -31,7 +31,7 @@ class TobiiController(TobiiNetworkInterface.TobiiNetworkInterface): calibration_id = None """Calibration identifier.""" - def __init__(self, ip_address, project_name = DEFAULT_PROJECT_NAME, participant_name = DEFAULT_PARTICIPANT_NAME): + def __init__(self, ip_address = None, project_name = DEFAULT_PROJECT_NAME, participant_name = DEFAULT_PARTICIPANT_NAME): """Create a project, a participant and start calibration.""" super().__init__(ip_address) @@ -185,7 +185,7 @@ class TobiiController(TobiiNetworkInterface.TobiiNetworkInterface): def calibrate(self): """Start Tobii glasses calibration for current project and participant.""" - input('Position Tobbi glasses calibration target then presse \'Enter\' to start calibration.') + input('Position Tobbi glasses calibration target then press \'Enter\' to start calibration.') data = { 'ca_project': self.project_id, diff --git a/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py b/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py index 52d0be5..2b55eb7 100644 --- a/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py +++ b/src/argaze/TobiiGlassesPro2/TobiiNetworkInterface.py @@ -92,8 +92,6 @@ class TobiiNetworkInterface(): logging.error("Device discovery is not available due to a missing dependency (netifaces)") exit(1) - logging.debug("Looking for a Tobii Pro Glasses 2 device ...") - MULTICAST_ADDR = 'ff02::1' PORT = 13006 @@ -114,18 +112,15 @@ class TobiiNetworkInterface(): PORT_OUT = PORT if sys.platform == 'win32' or sys.platform == 'darwin' else PORT + 1 try: + + # Sending discover request discover_json = '{"type":"discover"}' s6.sendto(discover_json.encode('utf-8'), (MULTICAST_ADDR, PORT_OUT)) - logging.debug("Discover request sent to %s on interface %s " % ( str((MULTICAST_ADDR, PORT_OUT)),if_name) ) - logging.debug("Waiting for a reponse from the device ...") - + # Waiting for a reponse from the device ... data, address = s6.recvfrom(1024) jdata = json.loads(data.decode('utf-8')) - logging.debug("From: " + address[0] + " " + str(data)) - logging.debug("Tobii Pro Glasses found with address: [%s]" % address[0]) - addr = address[0] if sys.version_info.major == 3 and sys.version_info.minor >= 8: @@ -134,9 +129,9 @@ class TobiiNetworkInterface(): return (jdata, addr) except: - logging.debug("No device found on interface %s" % if_name) - logging.debug("The discovery process did not find any device!") + # No device found on interface + pass return (None, None) -- cgit v1.1