#!/usr/bin/env python import argparse from argaze.TobiiGlassesPro2 import TobiiEntities, TobiiData, TobiiVideo import matplotlib.pyplot as mpyplot import matplotlib.patches as mpatches def main(): """ Explore Tobii Glasses Pro 2 interface's SD Card """ # manage arguments parser = argparse.ArgumentParser(description=main.__doc__.split('-')[0]) parser.add_argument('-d', '--drive_path', metavar='DRIVE_PATH', type=str, default=None, help='drive path') parser.add_argument('-p', '--project_path', metavar='PROJECT_PATH', type=str, default=None, help='project path') parser.add_argument('-r', '--recording_path', metavar='RECORDING_PATH', type=str, default=None, help='recording path') parser.add_argument('-s', '--segment_path', metavar='SEGMENT_PATH', type=str, default=None, help='segment path') args = parser.parse_args() if args.drive_path != None: # Load all projects from a tobii drive tobii_drive = TobiiEntities.TobiiDrive(args.drive_path) for project in tobii_drive.projects(): print(f'Project id: {project.id}, name: {project.name}') elif args.project_path != None: # Load one tobii project tobii_project = TobiiEntities.TobiiProject(args.project_path) for participant in tobii_project.participants(): print(f'Participant id: {participant.id}, name: {participant.name}') for recording in tobii_project.recordings(): print(f'Recording id: {recording.id}, name: {recording.name}') print(f'\tProject: {recording.project.name}') print(f'\tParticipant: {recording.participant.name}') elif args.recording_path != None: # Load a tobii segment tobii_recording = TobiiEntities.TobiiRecording(args.recording_path) for segment in tobii_recording.segments(): print(f'Segment id: {segment.id}') elif args.segment_path != None: # Load a tobii segment tobii_segment = TobiiEntities.TobiiSegment(args.segment_path) tobii_segment_video = tobii_segment.load_video() print(f'Video properties:\n\tduration: {tobii_segment_video.duration/1e6} s\n\twidth: {tobii_segment_video.width} px\n\theight: {tobii_segment_video.height} px') tobii_segment_data = tobii_segment.load_data() print(f'Loaded data count:') for name in tobii_segment_data.keys(): print(f'\t{name}: {len(tobii_segment_data[name])} data') # Edit figure figure_width = min(tobii_segment_video.duration/10, 56) # maximal width to display: 56 inches at 144 dpi < 2^16 pixels data_sample = 8064 # 56 inches * 144 dpi = 8064 data can be displayed at max figure = mpyplot.figure(figsize=(figure_width, 5), dpi=144) # Plot data subplot = figure.add_subplot(111) subplot.set_title('VideoTimeStamps', loc='left') patches = tobii_segment_data['VideoTimeStamp'].plot(names=['offset','value'], colors=['#276FB6','#9427B6'], samples=data_sample) subplot.legend(handles=patches, loc='upper left') # Display figure mpyplot.show() figure.clear() if __name__ == '__main__': main()