Class trifinger_cameras::PylonDriver

class PylonDriver : public robot_interfaces::SensorDriver<CameraObservation, CameraInfo>, public robot_interfaces::SensorDriver<CameraObservation, CameraInfo>

Driver for interacting with a camera via Pylon and storing images using OpenCV.

Public Functions

PylonDriver(const std::string &device_user_id, bool downsample_images = true, Settings settings = Settings())

Connect to camera based on name.

When using this constructor, the camera calibration coefficients returned by get_sensor_info will be set to zero.

Parameters:
  • device_user_id – “DeviceUserID” of the camera. Pass empty string to connect to first camera found (useful if only one camera is connected).

  • downsample_images – If set to true (default), images are downsampled to half their original size.

  • settingsSettings for the camera.

PylonDriver(const std::filesystem::path &camera_calibration_file, bool downsample_images = true, Settings settings = Settings())

Connect to camera based on calibration file.

The provided calibration file is expected to be in YAML format and contain the “camera_name” (= DeviceUserID) as well as calibration coefficients. The latter will be used in the CameraInfo returned by get_sensor_info.

Parameters:
  • camera_calibration_file – Path to the camera calibration file.

  • downsample_images – If set to true (default), images are downsampled to half their original size.

  • settingsSettings for the camera.

~PylonDriver()
virtual CameraInfo get_sensor_info() override

Get the camera parameters (image size and calibration coefficients).

Important: The calibration coefficients are only set if the driver is initialized with a calibration file (see constructor). Otherwise, they will be empty.

virtual CameraObservation get_observation() override

Get the latest observation (image frame + timestamp of when the frame’s grabbed).

Returns:

CameraObservation

PylonDriver(const std::string &device_user_id, bool downsample_images = true, Settings settings = Settings())

Connect to camera based on name.

When using this constructor, the camera calibration coefficients returned by get_sensor_info will be set to zero.

Parameters:
  • device_user_id – “DeviceUserID” of the camera. Pass empty string to connect to first camera found (useful if only one camera is connected).

  • downsample_images – If set to true (default), images are downsampled to half their original size.

  • settingsSettings for the camera.

PylonDriver(const std::filesystem::path &camera_calibration_file, bool downsample_images = true, Settings settings = Settings())

Connect to camera based on calibration file.

The provided calibration file is expected to be in YAML format and contain the “camera_name” (= DeviceUserID) as well as calibration coefficients. The latter will be used in the CameraInfo returned by get_sensor_info.

Parameters:
  • camera_calibration_file – Path to the camera calibration file.

  • downsample_images – If set to true (default), images are downsampled to half their original size.

  • settingsSettings for the camera.

~PylonDriver()
virtual CameraInfo get_sensor_info() override

Get the camera parameters (image size and calibration coefficients).

Important: The calibration coefficients are only set if the driver is initialized with a calibration file (see constructor). Otherwise, they will be empty.

virtual CameraObservation get_observation() override

Get the latest observation (image frame + timestamp of when the frame’s grabbed).

Returns:

CameraObservation

Public Static Functions

static cv::Mat downsample_raw_image(const cv::Mat &image)

Downsample raw Bayer pattern by factor 2.

Downsample a raw image by factor two, preserving the Bayer pattern.

Parameters:

image – Original image.

Returns:

Downsampled image.

static cv::Mat downsample_raw_image(const cv::Mat &image)

Downsample raw Bayer pattern by factor 2.

Downsample a raw image by factor two, preserving the Bayer pattern.

Parameters:

image – Original image.

Returns:

Downsampled image.