Skip to content

Capture Single Color Frame

SUMMARY

Capture Single Color Frame acquires one color frame from the camera and returns it as a NumPy array, ready to be logged, processed, or saved. It is the simplest operation against any 2D or 3D camera and the foundation of vision pipelines that don't need continuous streaming.

Available on: IDS, Webcam, Intel RealSense.

The Skill

python
image = camera.capture_single_color_frame()

Example

IDS

IDS single image capture output

Webcam

Webcam single image capture output

Intel RealSense

RealSense single RGB image capture output

The Code

python
"""
Connect to an IDS camera, get/set parameters, capture an image, and disconnect.

Run from a terminal to avoid issues with Rerun's spawn mode.
"""
from loguru import logger
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()

        logger.info(f"ExposureTime: {camera.get_parameter('ExposureTime')}")
        camera.set_parameter('ExposureTime', 35000.0)

        image = camera.capture_single_color_frame()

        rr.log("Single_Image_Capture", rr.Image(image))
    except Exception as e:
        logger.error(f"Unable to capture image. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()
python
"""
Connect to a webcam, capture a single color frame, and disconnect.

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

from telekinesis.medulla.cameras import webcam


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

        image = camera.capture_single_color_frame()

        rr.log("Single_Image_Capture", rr.Image(image))
    except Exception as e:
        logger.error(f"Unable to capture image. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()
python
"""
Connect to a RealSense camera, capture a single color frame, and disconnect.

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

from telekinesis.medulla.cameras import realsense


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

        image = camera.capture_single_color_frame()

        rr.log("Single_Image_Capture", rr.Image(image))
    except Exception as e:
        logger.error(f"Unable to capture image. {type(e).__name__}: {e}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()

The Explanation of the Code

After connect has opened the device, capture_single_color_frame acquires one color frame and returns it as a NumPy array. The returned array is RGB-ordered and can be passed directly to Rerun (rr.Image) or any downstream processing step.

python
image = camera.capture_single_color_frame()
rr.log("Single_Image_Capture", rr.Image(image))

Per-camera behavior:

  • IDS — switches the camera to SingleFrame acquisition mode, triggers one exposure, waits for the buffer to fill, and converts the raw buffer to a color image. Parameters such as ExposureTime can be tuned beforehand with set_parameter; see the IDS code tab above.
  • Webcam — reads one frame from the OpenCV VideoCapture device and converts it from BGR to RGB.
  • RealSense — activates the color stream, retrieves one frame, and returns it as a NumPy array.

The disconnect call lives in a finally block so the device is released regardless of whether the capture succeeded.

Running the Example

bash
python capture_image_example.py

A Rerun viewer opens automatically. The captured frame appears under Single_Image_Capture once acquisition completes.

Where to Use the Skill

  • Calibration and snapshot workflows — capture a single reference image to seed downstream processing.
  • Triggered inspection — acquire one frame on demand instead of running a continuous stream.
  • Pipelines that don't require video — feed Cornea or other vision modules with a single frame at a time.