LeRobot documentation

Cameras

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Cameras

Cameras supply the image observations a policy sees. Every backend — OpenCV, Intel RealSense, Reachy 2 — implements the Camera interface, so swapping hardware does not change the code that reads frames.

See the Cameras guide for choosing and configuring a camera, and Third-Party Cameras & Sensors for devices outside the core set.

Camera

class lerobot.cameras.Camera

< >

( config: CameraConfig )

Parameters

  • fps (float | None) — Configured or measured frames per second
  • width (int | None) — Frame width in pixels
  • height (int | None) — Frame height in pixels

Base class for camera implementations.

Defines a standard interface for camera operations across different backends. Subclasses must implement all abstract methods.

Manages basic camera properties (FPS, resolution) and core operations:

  • Connection/disconnection
  • Frame capture (sync/async/latest)

connect

< >

( warmup: bool = True )

Parameters

  • warmup — If True (default), captures a warmup frame before returning. Useful for cameras that require time to adjust capture settings. If False, skips the warmup frame.

Establish connection to the camera.

disconnect

< >

( )

Disconnect from the camera and release resources.

read

< >

( ) → np.ndarray

Returns

np.ndarray

Captured frame as a numpy array.

Capture and return a single frame from the camera synchronously.

This is a blocking call that will wait for the hardware and its SDK.

async_read

< >

( timeout_ms: float = Ellipsis ) → np.ndarray

Parameters

  • timeout_ms — Maximum time to wait for a new frame in milliseconds. Defaults to 200ms (0.2s).

Returns

np.ndarray

Captured frame as a numpy array.

Raises

TimeoutError

  • TimeoutError — If no new frame arrives within timeout_ms.

Return the most recent new frame.

This method retrieves the latest frame captured by the background thread. If a new frame is already available in the buffer (captured since the last call), it returns it immediately.

It blocks up to timeout_ms only if the buffer is empty or if the latest frame was already consumed by a previous async_read call.

Essentially, this method return the latest unconsumed frame, waiting if necessary for a new one to arrive within the specified timeout.

Usage:

  • Ideal for control loops where you want to ensure every processed frame is fresh, effectively synchronizing your loop to the camera’s FPS.
  • Causes of a timeout usually include: very low camera FPS, heavy processing load, or if the camera is disconnected.

find_cameras

< >

( ) → List[Dict[str, Any]]

Returns

List[Dict[str, Any]]

A list of dictionaries, where each dictionary contains information about a detected camera.

Detects available cameras connected to the system.

CameraConfig

class lerobot.cameras.CameraConfig

< >

( fps: int | None = Nonewidth: int | None = Noneheight: int | None = None )

make_cameras_from_configs

lerobot.cameras.make_cameras_from_configs

< >

( camera_configs: dict )

Update on GitHub