Getting Started with Intel RealSense on WendyOS: Stream Color, IR, and Depth in Python
Wendy Labs · Wendy Labs Team · May 20, 2026
Join our Discord community to connect with other developers building with WendyOS!
Here's what you'll have running on your device in a few minutes - all four RealSense D415 streams (color, left IR, right IR, and colorized depth) live in a browser:
TL;DR - skip the tutorial
If you just want to run it, one command scaffolds the full project:
That's it. The CLI cross-builds the multi-stage Docker image, ships it to your Jetson or Pi over USB-C, brings the container up with USB and host networking, and pops your browser open to the live RealSense streams.
The rest of this post walks through everything the template generated - useful if you want to understand the architecture, swap out the camera, add another stream, or fork it into something custom.
What you'll build
A four-stream live viewer for an Intel RealSense D415:
Color - the RGB sensor at up to 1080p
Left IR + Right IR - the stereo infrared pair
Depth - the depth map, run through librealsense's colorizer for visualization
Each stream is published as its own MJPEG endpoint, so the React frontend just drops them into <img> tags - no WebRTC, no custom decoder, no client-side library needed. A FastAPI server owns the pipeline, a single background thread polls frames, and HTTP handlers read the latest JPEG bytes per stream.
Prerequisites
A WendyOS or Linux device. This template runs great on:
NVIDIA Jetson - Orin Nano, AGX Orin, and the upcoming Jetson Thor
Raspberry Pi - Pi 4 and Pi 5 (with WendyOS or vanilla Ubuntu)
Any Ubuntu host - works fine on a plain x86_64 or aarch64 Ubuntu machine if you'd rather not flash a device
An Intel RealSense camera. The template defaults match the D415, but D435, D435i, and D455 work with the same code (you may need to tweak supported resolutions/FPS in src/App.tsx).
This pulls the realsense-camera template from the Wendy templates repo and writes it to ./realsense-generated-python/. The --assistant skip flag tells the CLI not to launch Claude Code or Codex afterwards - we want to read the code, not vibe-code on top of it.
usb entitlement - without this, the container can't see the RealSense over USB. WendyOS apps are sandboxed by default; you opt in to hardware access.
network host mode - port 8000 binds directly on the device's network stack, so any browser on the LAN can hit it without port mapping.
postStart hook - once the readiness probe (TCP on 8000) succeeds, the CLI runs wendy utils open-browser on your laptop, pointing at the device. This is what makes wendy run feel mobile-like: build, deploy, and the UI just opens.
Step 3: read the Python server - server/main.py
The server is one file, ~450 lines. The shape is:
RealSensePump ← owns the librealsense pipeline, runs one worker thread
↓ publishes latest JPEG per stream
FastAPI routes ← /stream/{id}, /start, /stop, /config, /health
The pump
RealSensePump wraps a single rs.pipeline() and enables all four streams at the configured resolution:
The background worker loops on pipeline.wait_for_frames(), encodes each frame to JPEG with OpenCV, and stores the latest bytes per stream under a Condition. The depth frame goes through rs.colorizer() first so you get the familiar blue/green/red depth gradient instead of raw uint16.
Two locks, strict order
The interesting part of the pump is the locking. Reconfiguring resolution or FPS needs to stop the pipeline, wait for the worker, and start a fresh one - without racing a new pipeline.start() against the old worker's pipeline.stop() for the USB device. The template uses two locks:
_lifecycle_lock - held by start, stop, and configure across the entire restart. The worker thread never touches it.
_lock - protects mutable state shared with the worker. Held briefly, never across a join (the worker takes it inside _apply_pending_preset, which would deadlock).
Lock order is always lifecycle first, then state. The worker only touches state, so inversion is impossible.
MJPEG streaming
Each /stream/{id} endpoint returns a StreamingResponse with multipart/x-mixed-replace. The iterator just reads the latest frame, yields it with an MJPEG boundary, and skips identical consecutive frames with a 5ms sleep to avoid hammering the client:
async def _mjpeg_iter(stream_id): last = None while True: frame = await asyncio.to_thread(pump.latest, stream_id, 5.0) if frame is None: break if frame is last: await asyncio.sleep(0.005) continue last = frame yield f"--{BOUNDARY}\r\n".encode() + b"Content-Type: image/jpeg\r\n" + ... + frame + b"\r\n"
When the user clicks Stop in the UI, pump.stop() clears _latest and notify_alls - latest() returns None, the iterator exits, and the HTTP connection closes cleanly.
Visual presets
The D415's depth sensor supports named presets (default, hand, high-accuracy, high-density, medium-density). Switching presets does not require restarting the pipeline - the template applies them live via set_option(visual_preset, ...) on the running depth sensor. Resolution and FPS changes do require a restart, which is why the lifecycle lock exists.
Routes
Route
Purpose
GET /stream/{id}
MJPEG stream (color, ir-left, ir-right, depth)
POST /start
Start the pump
POST /stop
Stop the pump
POST /config?width=&height=&fps=&preset=
Reconfigure (restarts pipeline if w/h/fps changed)
GET /health
Returns running state and per-stream FPS
GET /
Serves the built React SPA
The SPA mount happens after all API routes are registered, so /stream/*, /config, etc. take priority and everything else falls through to index.html.
Step 4: read the Dockerfile - three stages
# Stage 1 - Build the React/Vite frontendFROM node:22-alpine AS frontend-builderWORKDIR /buildCOPY package.json package-lock.json ./RUN npm install --no-audit --no-fundCOPY . ./RUN npm run build
Standard Vite build. The output lands in /build/dist.
This is the stage that earns its keep. Intel publishes librealsense debs for x86, but not for aarch64 - and Jetson and Pi are both aarch64. So we build it from source against v2.55.1 and copy the resulting pyrealsense2*.so and pybackend2*.so into a Python dist-packages directory.
-DFORCE_RSUSB_BACKEND=ON is important: it tells librealsense to use its userspace USB backend instead of the V4L2 kernel driver. WendyOS containers don't have access to host kernel modules, but USB passthrough via the usb entitlement works fine with the userspace backend.
The runtime stage is slim: Python, libusb, libssl, the librealsense libraries from stage 2, and the Python deps. The import pyrealsense2 sanity check fails the build early if the bindings aren't usable - much better than discovering it at runtime on the device.
Step 5: read the React frontend - src/App.tsx
The frontend is a single React component using shadcn primitives. The shape:
Four checkboxes - toggle which streams render
A resolution + FPS picker, with FPS options gated by what the D415 actually supports at each resolution
A preset dropdown that hits /config?preset=... for live updates
Start / Stop buttons that hit /start and /stop
A 2x2 grid of <img src="/stream/color">, <img src="/stream/ir-left">, etc.
The D415 firmware only resolves a fixed set of FPS values per stream profile, and color caps the combined set when all four streams are enabled. 90fps works on depth/IR alone at 480p, but color can't keep up - so the dropdown disables it rather than letting you pick something the pipeline will reject.
The <img> tags use a streamSession counter in the key to force a remount on Stop → Start, so the browser drops its old connection cleanly.
Step 6: deploy
cd realsense-generated-pythonwendy run
The CLI:
Discovers your default WendyOS device (or you pick one with --device)
Builds the multi-stage Docker image, cross-compiling for the device's architecture
Pushes it to the device's local registry
Brings the container up with the USB and network entitlements
Waits for the readiness probe on port 8000
Runs the postStart hook, which opens your browser to http://<device>.local:8000
Streams container logs back to your terminal
Plug a D415 in, hit Start, watch all four streams light up.
Where to go from here
A few ideas if you want to fork this into something:
Add a recorder - the pump already encodes JPEG; pipe those bytes into an .mp4 with ffmpeg-python.
Run YOLO on the color stream - drop in ultralytics and a YOLOv8 model, overlay boxes before encoding. The GPU entitlement gives you CUDA on Jetson.
Swap the camera - D435 and D455 use the same librealsense bindings. Just adjust the supported resolutions.
Stream over WebRTC instead of MJPEG - MJPEG is great for "drop into an <img>" simplicity, but WebRTC gets you sub-100ms latency.
The whole template is the kind of thing that's annoying to assemble from scratch - finding the right librealsense version, getting the aarch64 build right, handling pipeline restarts without deadlocking. wendy init --template realsense-camera gives you a working starting point.
Wendy Net is a private, zero trust network built into WendyOS. Devices connect over Ethernet, Wi-Fi, Wi-Fi Aware, Bluetooth Low Energy and Wendy Cloud, and your apps find each other with ordinary mDNS and talk over plain HTTP, TCP and UDP.
Build one small Python app that lets a Qualcomm Dragonwing IQ9, a Raspberry Pi 5 and an NVIDIA Jetson find each other, encrypt their messages and hold them when a board goes dark, all without an internet connection.
Wendy Labs · Wendy Labs Team
Get started
Start with one device. Close the loop around it.
Use WendyOS on your hardware or add Wendy Agent to an existing Linux or Apple Silicon Mac. Connect sensors, run your code, and carry what you learn into the next release.