Camera Interface
Camera Interface
medulla connects your code to real cameras, depth sensors, and other devices - so you can capture and stream live data. This tutorial walks through capturing a frame from a USB webcam.
Cameras
Camera skills connect to a physical camera, capture color/depth frames or point clouds, and stream them live. The example below connects to a USB webcam and visualizes a captured frame in Rerun - the same pattern applies to other supported cameras (see all supported cameras).
Hardware required
You need a USB webcam connected to your machine. A built-in laptop camera works too - camera_id=0 selects the default camera.
Run the Capture from Webcam using Medulla
Save the script
Create a file called quickstart_webcam_example.py anywhere on your machine and paste the following
"""Telekinesis quickstart: capture a single frame from a USB webcam.
Connects to the default webcam, captures one color frame, and visualizes
it in a Rerun viewer.
Run as a script - python quickstart_webcam_example.py
"""
import rerun as rr
from loguru import logger
from telekinesis.medulla.cameras import webcam
def main() -> None:
# Opens the Rerun viewer (spawn=True).
rr.init("telekinesis_medulla_quickstart", spawn=True)
# camera_id=0 is usually the default laptop camera or first USB webcam.
camera = webcam.Webcam(name="my_webcam_camera", camera_id=0)
try:
camera.connect()
# Skill call: Capture one color image as an HWC uint8 NumPy array.
image = camera.capture_color_image()
height, width = image.shape[:2]
logger.success(f"Captured a {width}x{height} frame")
# Log under entity path "webcam" so it appears in the spatial view.
rr.log("webcam", rr.Image(image))
except Exception as exc:
logger.error(f"Failed to capture frame: {exc!r}")
finally:
camera.disconnect()
if __name__ == "__main__":
main()Run the script!
python quickstart_webcam_example.pyWhere to Go Next?
Continue to the next tutorial.
Datatypes
The strongly typed contracts shared across every Skill and Agent.
Next tutorial →
