qmi.instruments.ptgrey.blackfly_aravis

Instrument driver for PtGrey BlackFly cameras via the Aravis library.

This driver depends on Aravis, a free library for video acquisition from Genicam cameras. Aravis is a C library based on GLib/GObject.

There is no Python module for Aravis. Instead, Aravis is accessed via the GObject Introspection framework. Therefore this driver depends on the Python module ‘gi’.

Aravis works under Linux and is NOT supported on Windows.

This driver requires that Aravis is installed on the system. When installed in a non-standard location, the directory containing libaravis-0.6.so must be added to LD_LIBRARY_PATH.

Aravis must be compiled with introspection enabled, and the Aravis typelib must be installed on the system. When installed in a non-standard location, the directory containing Aravis.typelib must be added to GI_TYPELIB_PATH.

Classes

CameraInfo(vendor_name, model_name, ...)

Camera device information.

ImageInfo(width, height, offset_x, offset_y, ...)

Image acquired from the camera.

PtGrey_BlackFly_Aravis(context, name[, ...])

Instrument driver for PtGrey BlackFly cameras via the Aravis library.

class qmi.instruments.ptgrey.blackfly_aravis.CameraInfo(vendor_name: str, model_name: str, serial_number: str, version: str, ip_address: str)

Camera device information.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

ip_address: str

Alias for field number 4

model_name: str

Alias for field number 1

serial_number: str

Alias for field number 2

vendor_name: str

Alias for field number 0

version: str

Alias for field number 3

class qmi.instruments.ptgrey.blackfly_aravis.ImageInfo(width: int, height: int, offset_x: int, offset_y: int, pixel_format: str, frame_id: int, image_id: int, timestamp: float, gain: float, black_level: float, exposure_time: float, data: ndarray)

Image acquired from the camera. :ivar width: Image width in pixels. :ivar height: Image height in pixels. :ivar offset_x: X offset within sensor area in pixels. :ivar offset_y: Y offset within sensor area in pixels. :ivar pixel_format: Pixel format description (GenICam PFNC name). :ivar frame_id: Frame sequence number. :ivar image_id: Unique image ID. :ivar timestamp: Timestamp in seconds, or 0.0 if not present. :ivar gain: Analog gain in dB, or 0.0 if not present. :ivar black_level: Black level in percent, or 0.0 if not present. :ivar exposure_time: Exposure time in microseconds, or 0.0 if not present. :ivar data: Pixel data as a 2D Numpy array.

black_level: float

Alias for field number 9

count(value, /)

Return number of occurrences of value.

data: ndarray

Alias for field number 11

exposure_time: float

Alias for field number 10

frame_id: int

Alias for field number 5

gain: float

Alias for field number 8

height: int

Alias for field number 1

image_id: int

Alias for field number 6

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

offset_x: int

Alias for field number 2

offset_y: int

Alias for field number 3

pixel_format: str

Alias for field number 4

timestamp: float

Alias for field number 7

width: int

Alias for field number 0

class qmi.instruments.ptgrey.blackfly_aravis.PtGrey_BlackFly_Aravis(context: QMI_Context, name: str, serial_number: str | None = None, ip_address: str | None = None)

Instrument driver for PtGrey BlackFly cameras via the Aravis library.

Although Aravis is a generic library for Genicam cameras, this driver is developed specifically for the PtGrey BFLY-GPE-31S4M-C camera. It is likely that the driver will also work with other monochrome Ethernet Genicam cameras. However modifications will be needed to support USB cameras and/or color cameras.

The driver currently only supports basic image control settings and simple image acquisition.

static list_instruments() List[CameraInfo]

Return a list of connected camera devices.

open() None

Connect to the instrument hardware.

When this method returns, the instrument must be ready for interaction via calls to instrument-specific methods.

Subclasses can extend this method to implement instrument-specific initialization. If they do, they should call super().open() as a last statement.

close() None

Close the connection to the instrument hardware and release associated resources.

When this method returns, the instrument must not be used again unless it is first re-opened by calling the open() method.

Subclasses can extend this method if they have specific resources to close. If they do, they should call super().close() as a last statement.

reset() None

Reset the camera.

Resetting triggers a complete reboot of the camera and involves temporarily closing and re-opening the network connection.

get_idn() QMI_InstrumentIdentification

Read instrument type and version and return a QMI_InstrumentIdentification instance.

get_ip_address() str

Return IP address of the camera device.

get_device_info() Dict[str, Any]

Return device information.

get_frame_rate() float

Return the acquisition frame rate in frames per second.

get_frame_rate_auto() str

Return the automatic frame rate mode (“Off”, “Once”, or “Continuous”).

set_frame_rate(frame_rate: float | None = None, auto_mode: str = 'Off') None

Set the acquisition frame rate and enable or disable automatic frame rate.

Parameters:
  • frame_rate – Frame rate in frame per second.

  • auto_mode – Automatic frame rate mode (“Off” or “Continuous”).

get_gain() float

Return analog gain in dB.

get_gain_auto() str

Return the automatic gain mode (“Off”, “Once”, or “Continuous”).

set_gain(gain: float | None = None, auto_mode: str = 'Off') None

Set analog gain in dB and enable or disable automatic gain.

Parameters:
  • gain – Analog gain in dB.

  • auto_mode – Automatic gain mode (“Off”, “Once”, or “Continuous”).

get_exposure_mode() str

Return the exposure mode (“Timed” or “TriggerWidth”).

set_exposure_mode(mode: str) None

Set the exposure mode.

Parameters:

mode – Exposure mode (“Timed” or “TriggerWidth”).

get_exposure_time() float

Return the exposure time in microseconds.

get_exposure_time_auto() str

Return the automatic exposure mode (“Off”, “Once” or “Continuous”).

set_exposure_time(exposure_time: float | None = None, auto_mode: str = 'Off') None

Set the exposure time and enable or disable automatic exposure.

Parameters:
  • exposure_time – Exposure time in microseconds.

  • auto_mode – Automatic exposure mode (“Off”, “Once” or “Continuous”).

get_pixel_format() str

Return pixel format (“Mono8”, “Mono12Packed” or “Mono16”).

set_pixel_format(pixel_format: str) None

Set format of the pixel data.

Parameters:

pixel_format – Format (“Mono8”, “Mono12Packed” or “Mono16”).

get_image_size() Tuple[int, int]

Return the current image size.

Returns:

Image size as tuple (width, height) in pixels.

set_image_size(width: int, height: int) None

Set the size of images provided by the camera.

A subset of the sensor area may be selected by setting the image size and image offset.

Parameters:
  • width – Width of image in pixels (must be a multiple of 4).

  • height – Height of image in pixels (must be a multiple of 2).

get_image_offset() Tuple[int, int]

Return the current image offset position.

Returns:

Offset position as tuple (x, y) in pixels.

set_image_offset(x: int, y: int) None

Set the image offset position.

Parameters:
  • x – Horizotal offset from the origin to the area of interest in pixels (must be a multiple of 2).

  • y – Vertical offset from the origin to the area of interest in pixels (must be a multiple of 2).

get_chunk_mode() Tuple[bool, Dict[str, bool]]

Return the current chunk data configuration.

Returns:

A tuple (chunk_data_active, chunk_types_enabled) where chunk_data_active is a boolean indicating whether chunk data is active and chunk_types_enabled is a dictionary indicating which chunk types are enabled.

set_chunk_mode(enable: bool) None

Enable or disable chunk data mode.

When chunk data mode is active, the camera adds some meta-data to each acquired image.

In principle, the camera supports separate enabling of specific meta-data types. However this function enables all meta-data types when chunk data mode is enabled.

get_device_temperature() float

Return the temperature of the camera in degrees Celcius.

get_transmit_failure_count() int

Return the number of failed transmissions since the last reset.

get_black_level() float

Return analog black level in percent.

set_black_level(level: float) None

Set analog black level.

Parameters:

level – Black level in percent.

set_indicator_mode(enable: bool) None

Enable or disable the indicator LED on the camera.

is_streaming() bool

Return True if the camera is in streaming mode.

start_acquisition(num_frames: int | None = None) None

Start frame acquisition.

Set acquisition mode and number of frames as specified, then start frame acquisition in the camera.

Call get_next_image() to fetch each image as it becomes available. Call stop_acquisition() to end the acquisition process.

Parameters:

num_frames – Number of frames to acquire, or None to set the camera in Continuous mode.

stop_acquisition() None

Stop frame acquisition in the camera.

get_next_image(timeout: float | None = None) ImageInfo

Return the next image from the current acquisition.

This function blocks until the next image is available. It then returns a named tuple containing image attributes as well as pixel data (as a Numpy array). The image is then released from the PySpin buffer.

This function must only be used when the camera is in acquisition mode (after start_acquisition()).

This function must only be called if a next image is expected (based on the num_frames parameter to start_acquisition()).

register_image_callback(callback: Callable[[ImageInfo], None]) None

Register callback function to be invoked when a new image becomes available.

Note that the callback function may be invoked from a background thread.

force_unlock() None

Forcefully unlock the remote object.

This unlocks the object, regardless of who owns the lock. This allows you to unlock an object if the locking proxy has been destroyed without unlocking.

Use this with care.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

classmethod get_category() str | None

Return the optional name of the category this object belongs to.

A category name is a free-form string that has no special significance. Its purpose is to distinguish between groups of RPC objects that fulfill similar roles.

get_name() str

Return the name of this object.

Returns:

name attribute.

get_signals() list[SignalDescription]

Return a list of signals that can be published by this object.

Returns:

List consisting of qmi_signals attributes.

is_locked() bool

Query if the remote object is locked.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

is_open() bool

Return True if the instrument is open (ready for interaction).

lock(timeout: float = 0.0, lock_token: str | None = None) bool

Lock the remote object. If timeout is given, try every 0.1s within the given timeout value. The remote object can be locked with an optional custom lock token by giving a string into lock_token keyword argument.

If successful, this proxy is the only proxy that can invoke RPC methods on the remote object; other proxies will receive an “object is locked” response. The return value indicates if the lock was granted; a denied lock means the object was already locked by another proxy.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

release_rpc_object() None

Give a warning if the instrument is removed while still open.

unlock(lock_token: str | None = None) bool

Unlock the remote object.

Without optional parameters, this is only allowed by the proxy that initially locked the object. By giving the lock token as an input parameter, the specific object locked by this token can be unlocked. The return value indicates if the unlocking was successful.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

unregister_image_callback(callback: Callable) None

Unregister the specified image callback function.