Skip to main content

Streaming and Visualizing All Live Sensor Data

Overview

This page shows how to run the code sample device_stream to:

  • Start and stop streaming data from Aria glasses over USB and Wi-Fi
  • Visualize the sensor streams from Aria's RGB, Mono Scene (SLAM), ET cameras and IMU sensors
note

These code samples require Python 3.9+ because of a fastplotlib dependency

Run device_stream

Example 1: Start and stop streaming over USB

  1. Plug your Aria glasses into your computer, using the provided USB cable
  2. From the samples directory in Terminal, run:
python -m device_stream --interface usb --update_iptables

You should then see:

Aria Live Stream Window
note

Cameras on Aria glasses are installed sideways. The visualizer rotates the raw image data for a more natural view.

  1. There are several ways you can stop streaming:
  • Press q or ESC to quit the app
  • Use Ctrl-C to terminate in terminal
  • Press the Capture button on your glasses

Example 2: Start and stop streaming over Wi-Fi

Streaming over Wi-Fi is similar, with a few extra steps.

  1. Connect your Aria Glasses and Computer to the same Wi-Fi compatible Wi-Fi network:
  2. Open the Mobile Companion app and tap Wi-Fi on the Dashboard to see your glasses' IP address
  3. From the samples directory in Terminal, run:
python -m device_stream --interface wifi --device-ip <Glasses IP> --update_iptables

Make sure you replace <Glasses IP> with the IP address you got from the Mobile Companion app

If you're on MacOS and lose internet connection, run aria-doctor in a separate terminal.

  1. Stop streaming using any of the methods listed in Example 1

Code walkthrough

1. Get StreamingManager instance

Use StreamingManager to start and stop streaming.

streaming_manager = device.streaming_manager

2. Configure Streaming Settings (optional)

Specify the profile name for the streaming in StreamingConfig, otherwise you'll use your glasses' default recording profile. If a default recording profile has not been set, you'll stream using profile18. Go to the Sensor Profiles page for supported profiles and their specs.

streaming_config = StreamingConfig()
streaming_config.profile_name = args.profile_name

Use ephemeral streaming certificates to protect your streamed data from being eavesdropped by other computer without certificate. This needs to be set to true when no persistent certificates were pre-installed. Go to the Streaming Internals page on the various aspects of streaming security and how certificates are used.

streaming_config.security_options.use_ephemeral_certs = True
streaming_manager.streaming_config = streaming_config

3. Start Streaming

Start streaming using all the previously set configurations.

streaming_manager.start_streaming()

4. Write callbacks for each sensor data stream

Create an observer class derived from BaseStreamingClientObserver defined in visualizer.py. Find the complex example named AriaVisualizerStreamingClientObserver in visualizer.py, which is used in this sample app to fetch and visualize data from each sensor.

Find a simpler example in undistort_rgb_image.py to fetch RGB data from the stream:

class StreamingClientObserver:
def __init__(self):
self.rgb_image = None

def on_image_received(self, image: np.array, record: ImageDataRecord):
self.rgb_image = image

5. Register callbacks in the streaming client

Once your observer class is defined, you will need to register it with a stream client object.

# get streaming client from the streaming manager
streaming_client = streaming_manager.streaming_client
# create custom visualizer and streaming client observer class instances
aria_visualizer = AriaVisualizer()
aria_visualizer_streaming_client_observer = AriaVisualizerStreamingClientObserver(aria_visualizer)
# register callbacks
streaming_client.set_streaming_client_observer(aria_visualizer_streaming_client_observer)

6. Visualize live stream

Subscribe to the live stream data and enter the rendering loop to visualize the streaming data until the window is closed.

streaming_client.subscribe()
aria_visualizer.render_loop()

7. Stop the stream & free resources

Once you've finished streaming, unsubscribe from StreamingClient instance, so that any held resources can be released, stop streaming and disconnect the device.

streaming_client.unsubscribe()
streaming_manager.stop_streaming()
device_client.disconnect(device)