FOR DEVELOPERS

Explore developer resources

Build. Integrate. Innovate. Learn how easy it is to transform your products and solutions with AI-powered eye-tracking from HarmonEyes.

Pupil Labs Neon Streaming Example

This example demonstrates real-time streaming with Pupil Labs Neon for live cognitive load and drowsiness predictions. See the API Reference section for detailed method documentation.

1. Initialize the SDK

import harmoneyes_theia

sdk = harmoneyes_theia.TheiaSDK(
    license_key="your-license-key-here",
    platform="PL", # Pupil Labs Neon
)

2. Start a Session

import uuid

session_id = str(uuid.uuid4())
sdk.start_new_session(
    session_uuid=session_id
)

3. Start Data Collection

# Start video streaming (optional)
sdk.start_realtime_video()

# Start eye tracking data collection
sdk.start_realtime_data()

4. Poll for Predictions

import time

start_time = time.time()  
duration = 400 #collecting data for 400 sec to record at least 3 updates for drowsiness level 
 
while (time.time() - start_time) < duration: 
   # Get cognitive load predictions 
    cog_levels, batch_num, _ = sdk.get_cog_load_levels() 
  
   if cog_levels is not None: 
        print(f"Cognitive Load: {cog_levels}") 
  
   # Get drowsiness level (updates every ~120 seconds) 
    drowsiness, drowsiness_batch = sdk.get_drowsiness_level() 
  
   if drowsiness is not None: 
        print(f"Drowsiness: {drowsiness}") 
  
   # Poll at 1Hz 
    time.sleep(1.0) 

5. Stop and Cleanup

sdk.stop_processing()