from pupil_labs.real_time_screen_gaze import marker_generator from pupil_labs.realtime_api.simple import discover_one_device from pupil_labs.real_time_screen_gaze.gaze_mapper import GazeMapper # Define the screen size screen_width = 1920 screen_height = 1080 # Define the marker vertices marker_verts = { 0: [ (0, 0), # Top left marker corner (20, 0), # Top right (20, 20), # Bottom right (0, 20), # Bottom left ], 1: [ (screen_width-20, 0), # Top right marker corner (screen_width, 0), # Top right (screen_width, 20), # Bottom right (screen_width-20, 20), # Bottom left ], 2: [ (screen_width-20, screen_height-20), # Bottom right marker corner (screen_width, screen_height-20), # Top right (screen_width, screen_height), # Bottom right (screen_width-20, screen_height), # Bottom left ], 3: [ (0, screen_height-20), # Bottom left marker corner (20, screen_height-20), # Top right (20, screen_height), # Bottom right (0, screen_height), # Bottom left ], } # Set up GazeMapper object device = discover_one_device() calibration = device.get_calibration() gaze_mapper = GazeMapper(calibration) # Add the screen surface screen_surface = gaze_mapper.add_surface(marker_verts, (screen_width, screen_height)) # Start mapping gaze to the screen device = discover_one_device(max_search_duration_seconds=10) while True: frame, gaze = device.receive_matched_scene_video_frame_and_gaze() result = gaze_mapper.process_frame(frame, gaze) for surface_gaze in result.mapped_gaze[screen_surface.uid]: print(f"Gaze at {surface_gaze.x}, {surface_gaze.y}")