ctu_bosch_sr450.basler_camera

Classes

BaslerCamera

A class to interface with a Basler camera.

Module Contents

class ctu_bosch_sr450.basler_camera.BaslerCamera

A class to interface with a Basler camera.

This class provides a simple interface to connect to, configure, and capture images from a Basler camera.

camera: pypylon.pylon.InstantCamera | None = None
converter: pypylon.pylon.ImageFormatConverter | None = None
connected: bool = False
opened: bool = False
__del__()

Destructor to ensure the camera is closed upon object deletion.

connect_by_name(name)

Connects to a camera by its user-defined name.

Parameters:

name (str) – The user-defined name of the camera to connect to.

Raises:
  • RuntimeException – If no camera with the specified name is found.

  • TypeError – If the camera name is not provided.

connect_by_ip(ip_addr)

Connects to a camera by its IP address.

Parameters:

ip_addr (str) – The IP address of the camera to connect to.

Raises:
  • RuntimeException – If no camera with the specified IP address is found.

  • TypeError – If the camera IP address is not provided.

open()

Opens the connection to the camera.

This method must be called after a successful connection has been made.

set_parameters(exposure_time=0.0, gain=0.0, gamma=1.0)

Sets the camera parameters.

Parameters:
  • exposure_time (float, optional) – The exposure time in microseconds. If 0, auto-exposure is used. Defaults to 0.0.

  • gain (float, optional) – The camera gain. If 0, auto-gain is used. Defaults to 0.0.

  • gamma (float, optional) – The gamma correction value. Defaults to 1.0.

grab_image(timeout=10000)

Grabs a single image from the camera.

Returns:

The captured image as a numpy array, or None if the grab fails.

Parameters:

timeout (int)

close()

Closes the connection to the camera.