from pupil_labs.realtime_api.simple import Device import time import cv2 import keyboard # Adjust this adress based on the phone connected to the Pupil Neon you are using (ask the IP) ip = "192.168.0.101" device = Device(address=ip, port="8080") # Print some info about the device print(f"Phone IP address: {device.phone_ip}") print(f"Phone name: {device.phone_name}") print(f"Battery level: {device.battery_level_percent}%") print(f"Free storage: {device.memory_num_free_bytes / 1024 ** 3:.1f} GB") print(f"Serial number of connected glasses: {device.serial_number_glasses}") try: while True: # read from local host aka unity udp if keyboard.is_pressed('r'): # if key 'q' is pressed recording_id = device.recording_start() print(f"Started recording with id {recording_id}") if keyboard.is_pressed('s'): # if key 'q' is pressed device.recording_stop_and_save() print("Recording stopped and saved") # matched = device.receive_matched_scene_and_eyes_video_frames_and_gaze() # if not matched: # print( # "Not able to find a match! Note: Pupil Invisible does not support " # "streaming eyes video" # ) # continue # # cv2.circle( # matched.scene.bgr_pixels, # (int(matched.gaze.x), int(matched.gaze.y)), # radius=40, # color=(0, 0, 255), # thickness=15, # ) # # # Render eyes video into the scene video # height, width, _ = matched.eyes.bgr_pixels.shape # matched.scene.bgr_pixels[:height, :width, :] = matched.eyes.bgr_pixels # # cv2.imshow( # "Scene camera with eyes and gaze overlay", matched.scene.bgr_pixels) # if cv2.waitKey(1) & 0xFF == 27: if keyboard.is_pressed('q'): device.close() print(f"Close session") break except KeyboardInterrupt: pass finally: print("Stopping connection ...") device.close()