diff options
author | Théo de la Hogue | 2022-03-22 16:08:02 +0100 |
---|---|---|
committer | Théo de la Hogue | 2022-03-22 16:08:02 +0100 |
commit | 880d8426bbf16dd9c91b85b7779eb221ac640cf0 (patch) | |
tree | 0975a4530c368ef3d6aea8add649343b28d1a29f | |
parent | 5d8f3db60a5b131005062407a515f7d4f8df7b0c (diff) | |
download | argaze-880d8426bbf16dd9c91b85b7779eb221ac640cf0.zip argaze-880d8426bbf16dd9c91b85b7779eb221ac640cf0.tar.gz argaze-880d8426bbf16dd9c91b85b7779eb221ac640cf0.tar.bz2 argaze-880d8426bbf16dd9c91b85b7779eb221ac640cf0.tar.xz |
Handling Tobii recording feature
-rw-r--r-- | src/argaze/TobiiGlassesPro2/TobiiController.py | 24 | ||||
-rw-r--r-- | src/argaze/utils/record_tobii_session.py | 67 |
2 files changed, 85 insertions, 6 deletions
diff --git a/src/argaze/TobiiGlassesPro2/TobiiController.py b/src/argaze/TobiiGlassesPro2/TobiiController.py index 10af5fe..0cc97f0 100644 --- a/src/argaze/TobiiGlassesPro2/TobiiController.py +++ b/src/argaze/TobiiGlassesPro2/TobiiController.py @@ -5,7 +5,7 @@ import tobiiglassesctrl class TobiiController(tobiiglassesctrl.TobiiGlassesController): """As TobiiController inherits from TobiiGlassesPyController, here is its [code](https://github.com/ddetommaso/TobiiGlassesPyController/blob/master/tobiiglassesctrl/controller.py).""" - project_id = None + project_name = None """Project identifier.""" participant_id = None @@ -14,14 +14,24 @@ class TobiiController(tobiiglassesctrl.TobiiGlassesController): calibration_id = None """Calibration identifier.""" + recording_id = None + """Recording identifier.""" + def __init__(self, ip_address, project_name, participant_id): """Create a project, a participant and start calibration.""" super().__init__(ip_address, video_scene = True) - self.project_id = super().create_project(project_name) - self.participant_id = super().create_participant(project_id, project_name) + self.project_name = project_name + self.project_id = super().create_project(self.project_name) + self.participant_id = super().create_participant(self.project_id, self.project_name) + def __del__(self): + pass + + def calibrate(self): + """Start Tobii glasses calibration""" + input('Position Tobbi glasses calibration target then presse \'Enter\' to start calibration.') self.calibration_id = super().create_calibration(self.project_id, self.participant_id) super().start_calibration(self.calibration_id) @@ -29,6 +39,8 @@ class TobiiController(tobiiglassesctrl.TobiiGlassesController): if not super().wait_until_calibration_is_done(self.calibration_id): raise Error('Tobii calibration failed') - # destruction - def __del__(self): - pass + def record(self): + """Enable recording on the Tobii interface's SD Card""" + + self.recording_id = super().create_recording(self.participant_id) + super().start_recording(self.recording_id) diff --git a/src/argaze/utils/record_tobii_session.py b/src/argaze/utils/record_tobii_session.py new file mode 100644 index 0000000..a92d818 --- /dev/null +++ b/src/argaze/utils/record_tobii_session.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +import argparse +import time + +from argaze.TobiiGlassesPro2 import * + +import cv2 as cv + +def main(): + """ + Record a Tobii Glasses Pro 2 session on Tobii interface's SD Card + """ + + # manage arguments + parser = argparse.ArgumentParser(description=main.__doc__.split('-')[0]) + parser.add_argument('-t', '--tobii_ip', metavar='TOBII_IP', type=str, default='192.168.1.10', help='tobii glasses ip') + parser.add_argument('-p', '--project_name', metavar='PROJECT_NAME', type=str, default='Untitled project', help='project name') + parser.add_argument('-i', '--participant_id', metavar='PARTICIPANT_ID', type=int, default=1, help='participant identifier') + args = parser.parse_args() + + # create tobii controller + tobii_controller = TobiiController.TobiiController(args.tobii_ip, args.project_name, args.participant_id) + + # calibrate tobii glasses + tobii_controller.calibrate() + + # start tobii glasses streaming + tobii_controller.start_streaming() + + # start recording + tobii_controller.record() + + # waiting until keyboard interruption + try: + + last_battery_level = 0 + time_count = 0 + while True: + + # print storage info each minutes + if time_count % 60 == 0: + + print(tobii_controller.get_storage_info()) + + # print battery level each time it changes + battery_level = tobii_controller.get_battery_level() + if battery_level != last_battery_level: + + print(tobii_controller.get_battery_info()) + last_battery_level = battery_level + + # sleep + time.sleep(1) + time_count += 1 + + # exit on keyboard interruption + except KeyboardInterrupt: + pass + + # stop tobii controller + tobii_controller.stop_streaming() + tobii_controller.close() + +if __name__ == '__main__': + + main()
\ No newline at end of file |