Skip to content

Stream Live Color Video ​

SUMMARY

Stream Live Color Video acquires continuous color frames in a loop, returning each frame as a NumPy array ready to log, encode, or process. The camera stays in continuous acquisition mode between calls, so frame rate is bounded only by the device and any optional encoding step.

Available on: IDS, Webcam, Intel RealSense.

The Skill ​

python
image = camera.capture_video_color_frame()

Call repeatedly inside a loop. The first call switches the camera to continuous acquisition; subsequent calls return the next frame.

Example ​

IDS

Webcam

Intel RealSense

The Code ​

python
"""
Stream live color video from an IDS camera, with parameter tuning and JPEG
encoding to reduce bandwidth before logging to Rerun.

Run from a terminal to avoid issues with Rerun's spawn mode.
"""
import time
from loguru import logger

import cv2
import rerun as rr

from telekinesis.medulla.cameras import ids


def main():
    camera = ids.IDS(
        name="my_ids_camera",
        serial_number="4108909352",
        load_factory_defaults=False,
    )
    try:
        rr.init("IDS_Example", spawn=True)
        camera.connect()

        camera.set_parameter('ExposureTime', 35000.0)
        camera.set_parameter('AcquisitionFrameRate', 14.0)

        end_time = time.time() + 10
        while time.time() < end_time:
            image = camera.capture_video_color_frame()
            if image is not None:
                _, encoded = cv2.imencode('.jpg', image, [cv2.IMWRITE_JPEG_QUALITY, 80])
                rr.log(
                    "Continuous_Image_Capture",
                    rr.EncodedImage(contents=encoded, media_type="image/jpeg"),
                )
    except Exception as e:
        logger.error(f"Unable to run video capture. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()
python
"""
Stream live color video from a webcam, logging each frame to Rerun.

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 webcam


def main():
    camera = webcam.Webcam(name="my_webcam_camera", camera_id=0)
    try:
        rr.init("Webcam_Example", spawn=True)
        camera.connect()

        end_time = time.time() + 10
        while time.time() < end_time:
            image = camera.capture_video_color_frame()
            rr.log("Continuous_Image_Capture", rr.Image(image))
    except Exception as e:
        logger.error(f"Unable to stream video. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()
python
"""
Stream live color video from a RealSense camera, logging each frame to Rerun.

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


def main():
    camera = realsense.RealSense(name="my_realsense_camera")
    try:
        rr.init("RealSense_Video_Example", spawn=True)
        camera.connect()

        end_time = time.time() + 10
        while time.time() < end_time:
            image = camera.capture_video_color_frame()
            if image is None:
                logger.warning("Image is none")
                continue
            rr.log("Continuous_Image_Capture", rr.Image(image))
    except Exception as e:
        logger.error(f"Unable to stream video. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()

Running the Example ​

bash
python capture_video_example.py

A Rerun viewer opens automatically. Frames stream under Continuous_Image_Capture for 10 seconds, then the camera disconnects cleanly.

Parameter Configuration ​

capture_video_color_frame() takes no parameters on IDS, Webcam, or RealSense. IDS acquisition settings such as AcquisitionFrameRate and ExposureTime are configured separately with set_parameter before the streaming loop starts.

Returns ​

TypeDescription
np.ndarrayRGB image of shape (H, W, 3), dtype uint8.
NoneIDS and RealSense return None if a frame could not be retrieved for that call (e.g. a transient buffer or protocol error); the caller is expected to skip the frame and try again on the next call.

Raises ​

ExceptionCondition
RuntimeErrorThe camera is not connected (RealSense, Webcam).
RuntimeErrorWebcam only — a frame could not be read from the OpenCV device.

IDS does not raise on a capture failure; the error is logged internally and the call returns None instead.

Where to Use the Skill ​

  • Live monitoring — display continuous video for inspection, calibration, or robot teleoperation.
  • Vision pipelines that consume video — feed downstream modules such as Cornea with a live feed.
  • Local debugging — when remote streaming over BabyROS isn't needed; for that, see Publish Video with BabyROS.