Camera Telemetry

Streams live camera video to Serial Studio over UDP alongside FPS and frame count telemetry using JPEG image autodetection.

Open in the examples browser Files on GitHub

Camera Telemetry dashboard in Serial Studio

What you'll learn: an Image View group fed by JPEG autodetection over UDP, alongside a Data Grid with FPS and frame count.

Prerequisites: Serial Studio Pro and Python 3 with opencv-python. A webcam is optional because the script has a synthetic test pattern.

Overview

Streams live camera video to Serial Studio over UDP at a target frame rate (30 FPS by default). Only FPS and frame count are sent alongside the image.

No microcontroller needed. A standard webcam or built-in laptop camera is all you need. A synthetic test pattern is available when no camera is connected (--no-camera).

What it streams

Image data (Image View widget)

Raw JPEG frames sent directly over UDP. The Image View widget uses autodetect mode: it finds frames by their FF D8 FF magic bytes and FF D9 end-of-image marker, independently of the CSV telemetry parser.

Telemetry (Performance group)

Index Metric Description
1 FPS Actual stream frame rate
2 Frame Count Total frames sent since start

Frame format

Two types of data share the same UDP byte stream:

JPEG image frame. Raw bytes, no extra framing. Autodetected by magic bytes.

CSV telemetry frame. Wrapped in a 3-byte start sentinel and 2-byte end sentinel:

AB CD EF  fps,frame_count  FE ED

Example (hex):

AB CD EF 32 39 2E 38 2C 31 30 32 34 FE ED
         2  9  .  8  ,  1  0  2  4

The sentinels are chosen so they are unlikely to occur in JPEG, PNG, BMP, or WebP compressed data. AB CD EF isn't a valid JPEG marker sequence and doesn't arise from JPEG byte-stuffing rules. The FrameReader extracts only bytes between the two sentinels. The ImageFrameReader ignores ASCII telemetry packets since they carry no image magic bytes.

How to run

The project includes a control loop that launches camera_telemetry.py --no-camera automatically when you connect, so for a no-hardware demo you can skip straight to Step 3 and click Connect. Run the script by hand (Steps 1 and 2) when you want a real camera or custom options.

Step 1: install dependencies

pip install opencv-python

Step 2: start the script

python3 camera_telemetry.py

Options:

Option Default Description
--camera INDEX 0 Camera device index
--port PORT 9000 UDP destination port
--fps FPS 30 Target frame rate
--quality Q 85 JPEG quality (1 to 100)
--no-camera off Use a synthetic test pattern
python3 camera_telemetry.py --no-camera          # no hardware needed
python3 camera_telemetry.py --camera 1           # secondary camera
python3 camera_telemetry.py --fps 60             # push a higher rate
python3 camera_telemetry.py --quality 60         # smaller packets

Step 3: configure Serial Studio

  1. Open Serial Studio and load Camera Telemetry.ssproj.
  2. In the Setup panel, set Connection → Network Socket, Socket Type → UDP.
  3. Set Local Port to 9000 (or whatever --port you used).
  4. Click Connect.

Performance tips

  • Lowering --quality cuts JPEG size and UDP fragmentation pressure. Quality 60 to 75 is usually enough for 640x480 preview.
  • Frames wider than 640 px are automatically downscaled before encoding.
  • The synthetic pattern (--no-camera) animates a color gradient with a moving circle. Useful for testing without any camera hardware.

Dependencies

  • Python 3.8 or later.
  • opencv-python. pip install opencv-python.
  • Serial Studio Pro (Image View widget, for the Camera Feed group).

License

Copyright (C) 2020-2025 Alex Spataru SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-SerialStudio-Commercial