Camera Streaming
Stream live video from USB webcams or Raspberry Pi Camera Modules directly to your Plexus dashboard. The agent auto-detects connected cameras and streams JPEG frames over WebSocket in real time.
Install
For USB cameras (OpenCV):
pip install plexus-agent[camera]For Raspberry Pi Camera Module (v1, v2, v3, HQ Camera):
pip install plexus-agent[picamera]Quick Start
The agent auto-detects cameras when you run plexus start or plexus run. No extra flags needed.
plexus start --key plx_xxxxxWhen cameras are detected, the agent reports them to the dashboard. You can then start and stop video streams from the dashboard UI by adding a Video panel to any dashboard.
How It Works
- The agent scans for connected cameras on startup (Pi cameras first, then USB)
- Camera metadata (name, resolution, capabilities) is sent to the dashboard
- When you open a Video panel, the dashboard sends a
start_cameracommand - The agent captures frames at the configured frame rate, encodes as JPEG, and streams over WebSocket
- Frames are relayed through the PartyKit server to all connected browsers
- When the Video panel is closed, streaming stops automatically
Configuration
USB Camera
from plexus.cameras import USBCamera
camera = USBCamera(
device_index=0, # Camera index (0 = first, 1 = second)
frame_rate=15.0, # Frames per second (default: 15)
resolution=(640, 480), # Width x height (default: 640x480)
quality=80, # JPEG quality 1-100 (default: 80)
camera_id="front-cam", # Custom ID (default: "usb:0")
)Raspberry Pi Camera
from plexus.cameras import PiCamera
camera = PiCamera(
camera_num=0, # Camera number (default: 0)
frame_rate=30.0, # Frames per second (default: 30)
resolution=(1280, 720), # Width x height (default: 1280x720)
quality=85, # JPEG quality 1-100 (default: 85)
camera_id="pi-cam", # Custom ID (default: "picam:0")
)Parameters
| Parameter | Type | USB Default | Pi Default | Description |
|---|---|---|---|---|
frame_rate | float | 15 fps | 30 fps | Target frames per second |
resolution | (int, int) | (640, 480) | (1280, 720) | Frame width and height in pixels |
quality | int | 80 | 85 | JPEG encoding quality (1-100). Lower = smaller frames, faster streaming |
camera_id | str | "usb:{index}" | "picam:{num}" | Unique identifier for this camera |
tags | dict | {} | {} | Metadata tags attached to every frame |
Auto-Detection
The agent scans for cameras automatically:
from plexus.cameras import scan_cameras
detected = scan_cameras()
for cam in detected:
print(f"{cam.name}: {cam.device_id}")Pi cameras are scanned first. Their V4L2 device indices are excluded from the USB scan to prevent conflicts between picamera2 and OpenCV accessing the same device.
Auto-Detection with Overrides
from plexus.cameras import auto_cameras
# Auto-detect all cameras with custom settings
hub = auto_cameras(
frame_rate=10, # Override FPS for all cameras
resolution=(1024, 768), # Override resolution for all
quality=70, # Override quality for all
)Multi-Camera Setup
Use CameraHub to manage multiple cameras:
from plexus.cameras import CameraHub, USBCamera, PiCamera
hub = CameraHub()
hub.add(USBCamera(device_index=0, camera_id="front"))
hub.add(USBCamera(device_index=1, camera_id="rear"))
hub.add(PiCamera(camera_num=0, camera_id="overhead"))Each camera streams independently and appears as a separate video source in the dashboard.
Dashboard Video Panel
To view a camera feed in the dashboard:
- Open a dashboard and click Add Panel
- Select Video as the panel type
- Choose the device and camera from the dropdowns
- The stream starts automatically
The video panel shows:
- Live JPEG frames rendered in real time
- A green pulsing indicator when streaming is active
- Frame dimensions (e.g., 640x480)
Shared dashboard viewers can watch camera feeds in read-only mode without being able to start or stop streams.
CLI Flags
# Auto-detect cameras (default behavior)
plexus run
# Disable camera auto-detection
plexus run --no-camerasTroubleshooting
USB camera not detected:
- Check permissions:
sudo usermod -aG video $USER(then log out and back in) - Verify the device exists:
ls /dev/video* - Run
plexus doctorto diagnose permission issues
Pi camera not detected:
- Enable the camera interface:
sudo raspi-config→ Interface Options → Camera - Check
libcamerais working:libcamera-hello --list-cameras - Ensure
picamera2is installed:pip install plexus-agent[picamera]
High latency or choppy video:
- Lower the resolution:
resolution=(320, 240) - Lower the frame rate:
frame_rate=5 - Lower JPEG quality:
quality=50 - Check your network bandwidth between the device and the Plexus server
Next Steps
- Serial / GPS -- Read serial devices and GPS receivers
- System Metrics -- Monitor CPU, memory, disk, and thermals
- CLI Reference -- Full list of
plexuscommands and flags