Debugging With the Streamer

../_images/streamer.png

View Videos, Images, and Text Data

Many devices won’t have a graphical connection set up, so the Streamer is provided to make debugging easier. The Streamer class can be used to display real-time and batch-processed video, image, and text data.

For real-time streaming, use the following command to initialize and start the Streamer:

with edgeiq.Streamer() as streamer:

To update the Streamer with the latest video frame and text data, use the send_data() function:

streamer.send_data(frame, text)

The text field takes in a list of strings, and each string will be displayed on its own line in the output section of the Streamer.

Once the Streamer starts, it will print a link in the console logs.

[INFO] Streamer started at http://localhost:5000

To display batch-processed images in a format similar to a slideshow, set the queue depth large enough to store all processed images and set the desired delay between frames. Then call the wait() function once all images have been added to the queue to keep the server up for all images to be displayed:

with edgeiq.Streamer(
      queue_depth=len(image_paths), inter_msg_time=3) as streamer:
  for image in image_paths:
    ...
    <some code>
    ...
    streamer.send_data(image, text)
  streamer.wait()

The Streamer will be automatically cleaned up when the code block exits.

Stop Your App With the Streamer

The Streamer can also be used to stop your app using the red stop button in the output box. For real-time apps, the check_exit() function will return true if the stop button has been pressed, so it can be used to exit long-running loops:

while True:
  # Perform processing

  ...

  if streamer.check_exit():
    break

For batch-processing mode, the stop button status is checked in the wait() function and will exit at the next wakeup.