basler

Basler camera backend.

This module defines a Basler camera backend using the pypylon SDK for the shared RGB camera interface. It provides camera discovery utilities and a concrete RGBCamera implementation with configurable exposure/gain behavior, optional camera intrinsics handling, and low-latency image acquisition. The module enables Basler hardware to integrate seamlessly into robotblockset camera and calibration workflows.

Key functionalities include: - Basler device discovery via transport-layer enumeration. - Concrete RGBCamera implementation for Basler RGB streams. - Camera selection by serial number and connection lifecycle management. - Configurable manual/auto exposure and gain controls. - RGB image retrieval in uint8 and float formats with low-latency grabbing strategy. - Optional intrinsics matrix support for calibration-aware pipelines.

robotblockset.cameras.basler.list_basler_cameras() None[source]

Print discovered Basler cameras.

This helper enumerates transport-layer devices visible to pypylon and prints each camera IP address and serial number.

Return type:

None

class robotblockset.cameras.basler.BaslerRGBCamera(serial_number: str | None = None, *, intrinsics_matrix: ndarray | None = None, exposure_time_us: float | None = None, gain: float | None = None, auto_exposure: bool | None = None, auto_gain: bool | None = None, frame_timeout_ms: int = 2000)[source]

Bases: RGBCamera

Basler RGB camera implementation compatible with the RGBCamera interface.

Notes

Requires pypylon (Basler pylon SDK Python bindings). Returns RGB images (H, W, 3) as uint8 or float32 in [0, 1] and uses GrabStrategy_LatestImageOnly to keep latency low.

Initialize a Basler RGB camera wrapper.

Parameters:
  • serial_number (str, optional) – Target camera serial number. If omitted, the first discovered camera is used.

  • intrinsics_matrix (CameraIntrinsicsMatrixType, optional) – Camera intrinsics matrix with shape (3, 3).

  • exposure_time_us (float, optional) – Manual exposure time in microseconds.

  • gain (float, optional) – Manual gain value.

  • auto_exposure (bool, optional) – Enable/disable continuous exposure auto mode.

  • auto_gain (bool, optional) – Enable/disable continuous gain auto mode.

  • frame_timeout_ms (int, optional) – int, default=2000 Timeout for frame acquisition in milliseconds.

Raises:

ValueError – If intrinsics_matrix does not have shape (3, 3).

Name: str = 'BaslerRGBCamera'
__init__(serial_number: str | None = None, *, intrinsics_matrix: ndarray | None = None, exposure_time_us: float | None = None, gain: float | None = None, auto_exposure: bool | None = None, auto_gain: bool | None = None, frame_timeout_ms: int = 2000) None[source]

Initialize a Basler RGB camera wrapper.

Parameters:
  • serial_number (str, optional) – Target camera serial number. If omitted, the first discovered camera is used.

  • intrinsics_matrix (CameraIntrinsicsMatrixType, optional) – Camera intrinsics matrix with shape (3, 3).

  • exposure_time_us (float, optional) – Manual exposure time in microseconds.

  • gain (float, optional) – Manual gain value.

  • auto_exposure (bool, optional) – Enable/disable continuous exposure auto mode.

  • auto_gain (bool, optional) – Enable/disable continuous gain auto mode.

  • frame_timeout_ms (int, optional) – int, default=2000 Timeout for frame acquisition in milliseconds.

Raises:

ValueError – If intrinsics_matrix does not have shape (3, 3).

connect() None[source]

Connect to the camera and start grabbing.

Return type:

None

Raises:
  • ImportError – If pypylon is not available.

  • RuntimeError – If the configured camera serial number cannot be found.

disconnect() None[source]

Stop grabbing and close the camera.

Return type:

None

property fps: float

Return the configured acquisition frame rate.

Returns:

Frame rate in Hz when available; nan if the camera does not expose the relevant node.

Return type:

float

Raises:

RuntimeError – If the camera is not connected.

property resolution: Tuple[int, int]

Return camera resolution in pixels.

Returns:

(width, height) in pixels.

Return type:

CameraResolutionType

Raises:

RuntimeError – If resolution is unavailable because the camera is not connected and no cached frame size exists.

intrinsics_matrix() ndarray[source]

Return the camera intrinsics matrix.

Returns:

Intrinsics matrix with shape (3, 3) in pixel units.

Return type:

CameraIntrinsicsMatrixType

Raises:

RuntimeError – If intrinsics were not provided at construction.

Functions

list_basler_cameras()

Print discovered Basler cameras.

Classes

BaslerRGBCamera([serial_number, ...])

Basler RGB camera implementation compatible with the RGBCamera interface.