Streamer

class Streamer(queue_depth=2, inter_msg_time=0, drop_frames=True)

Host a video and data streaming server on the device.

Streamer can be instantiated as a context manager:

with edgeiq.Streamer() as streamer:
    ...

To use Streamer directly, use the setup() and close() functions:

streamer = edgeiq.Streamer().setup()
...
streamer.close()

For a video stream, the default parameters are all you need. The Streamer web page has a “stop” button which you can check with the check_exit() function:

with edgeiq.Streamer() as streamer:
    while True:
        <get video frame>
        streamer.send_data(frame, 'This will be printed on the Streamer')

        if streamer.check_exit():
            break

For a series of images (slideshow mode), set the queue depth to the total number of images to be displayed, and set the inter-message time to the time in seconds you’d like each image to be displayed. Note that the inter-message time doesn’t take into account any delay in sending the message to the Streamer. You’ll also need to call the wait() function to make sure the app keeps running until all images have been sent to the web page. The “stop” button also works in this mode, but doesn’t need an explicit check since it’s checked in the wait() function.

with edgeiq.Streamer(
        queue_depth=len(image_list), inter_msg_time=4) as streamer:
    for image in image_list:
        streamer.send_data(image, 'This image will be displayed for 4 seconds')

    streamer.wait()
Parameters
  • queue_depth (integer) – The depth of the data queue used for communication between the application process and server process.

  • inter_msg_time (float) – The time in seconds between message sends to attached clients.

  • drop_frames (boolean) – Indicates whether send_data() should block when queue is full or drop frames.

setup()

Setup and start the streamer.

Returns

self

send_data(image=None, text=None)

Send image and text data to be displayed by the streamer.

Parameters
  • image (numpy array) – The image to be displayed by the streamer.

  • text (object or list of objects that can be converted to strings.) – The text to be displayed by the streamer. If a list, each element is shown on its own line on the streamer.

Raises

Any exception that occurs in Streamer process

wait()

Wait for all packets in the queue to be sent.

Will exit if the “stop” button has been pressed.

Raises

Any exception that occurs in Streamer process

check_exit()

Check if the “stop” button has been pressed.

close()

Stop the Streamer server.

Raises

Any exception that occurs in Streamer process