Stream Live Depth Video
SUMMARY
Stream Live Depth Video acquires continuous depth frames in a loop, returning each frame as a DepthImage whose .depth array holds float values in metres. Pair with a Rerun DepthImage colour map for a live false-colour visualisation of distance over time.
Available on: Intel RealSense.
The Skill
depth_image = camera.capture_depth()Call repeatedly inside a loop. Each call returns the next depth frame as a datatypes.DepthImage; the metric depth array is depth_image.depth.
Example
The Code
"""
Stream live depth video from a RealSense camera with a turbo colour map.
Run from a terminal to avoid issues with Rerun's spawn mode.
"""
import time
from loguru import logger
import rerun as rr
from telekinesis.medulla.cameras import realsense
from telekinesis.medulla.cameras.realsense import StreamProfile
def main():
camera = realsense.RealSenseD435I(name="my_realsense_camera")
try:
rr.init("RealSense_Video_Example", spawn=True)
camera.connect(serial_number="123456789012")
camera.set_parameter(
"stream_profile",
StreamProfile.from_strings("depth", 1280, 720, "z16", 30),
)
end_time = time.time() + 10
while time.time() < end_time:
depth_image = camera.capture_depth()
rr.log(
"Continuous_Depth_Image_Capture",
rr.DepthImage(
depth_image.depth,
meter=1.0, # values are already in metres
colormap="turbo",
depth_range=(0.0, 3.0), # 0–3 metres
),
)
except Exception as e:
logger.error(f"Unable to stream video. {type(e).__name__}: {e}")
finally:
rr.disconnect()
camera.disconnect()
if __name__ == "__main__":
main()Running the Example
python capture_depth_video_example.pyA Rerun viewer opens automatically. Depth frames stream under Continuous_Depth_Image_Capture for 10 seconds with the turbo colour map applied, then the camera disconnects cleanly.
Parameter Configuration
capture_depth() takes no parameters. The camera is selected with connect(serial_number=...), and stream resolution, format and frame rate are configured separately by setting the stream_profile parameter with a StreamProfile, e.g. StreamProfile.from_strings("depth", 1280, 720, "z16", 30). See connect and set_parameter.
Returns
| Type | Description |
|---|---|
datatypes.DepthImage | Depth image aligned to the colour sensor. .depth has shape (H, W), dtype float32, values in metres. Pixels with no valid depth reading are 0.0. |
Raises
| Exception | Condition |
|---|---|
RuntimeError | The camera is not connected (the RealSense pipeline has not been started), or no depth frame could be captured. |
Where to Use the Skill
- Live distance monitoring — observe how depth changes as the scene or robot moves.
- Calibration sanity checks — verify the depth pipeline is producing valid frames continuously.
- Mixed-mode pipelines — combine with
stream_live_color_videowhen both colour and depth feeds are needed.